예제 #1
0
    def get_info(self):
        """
        Returns Object-Count and Bytes-Used.
        """

        if not os.path.isdir(self.datadir):
            return

        files = do_listdir(self.datadir)
        files_count = len(files)
        for file in files:
            dir_bytes_used += do_stat(self.datadir + '/' + file).st_size

        return files_count, dir_bytes_used
예제 #2
0
    def unlinkold(self, timestamp):
        """
        Remove any older versions of the object file.  Any file that has an
        older timestamp than timestamp will be deleted.

        :param timestamp: timestamp to compare with each file
        """
        timestamp = normalize_timestamp(timestamp)
        for fname in do_listdir(self.datadir):
            if fname < timestamp:
                try:
                    do_unlink(os.path.join(self.datadir, fname))
                except OSError, err:    # pragma: no cover
                    if err.errno != errno.ENOENT:
                        raise
예제 #3
0
    def unlink(self):
        """
        Remove the file.
        """
        #Marker dir.
        if self.is_dir:
            rmdirs(os.path.join(self.datadir, self.obj))
            if not os.path.isdir(os.path.join(self.datadir, self.obj)):
                self.metadata = {}
                self.data_file = None
            else:
                logging.error('Unable to delete dir %s' % os.path.join(self.datadir, self.obj))
            return

        for fname in do_listdir(self.datadir):
            if fname == self.obj:
                try:
                    do_unlink(os.path.join(self.datadir, fname))
                except OSError, err:
                    if err.errno != errno.ENOENT:
                        raise