Beispiel #1
0
 def delete(self):
     if self.empty():
         #For delete account.
         if os.path.ismount(self.datadir):
             clean_metadata(self.datadir)
         else:
             rmdirs(self.datadir)
         self.dir_exists = False
Beispiel #2
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
         return
     for fname in os.listdir(self.datadir):
         #name, ext = fname.rsplit('.', 1)
         if fname == self.obj:
             try:
                 os.unlink(os.path.join(self.datadir, fname))
             except OSError, err:
                 if err.errno != errno.ENOENT:
                     raise
Beispiel #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
Beispiel #4
0
 def unlink(self):
     """
     Remove directory/container if empty.
     """
     if dir_empty(self.datadir):
         rmdirs(self.datadir)
Beispiel #5
0
                try:
                    os.unlink(os.path.join(self.datadir, fname))
                except OSError, err:
                    if err.errno != errno.ENOENT:
                        raise

        if self.obj_path:
            obj_dirs = self.obj_path.split('/')
            tmp_path = self.obj_path
            if len(obj_dirs):
                while tmp_path:
                    #TODO: Check dir is empty (Done in rmdirs)
                    dir_path = os.path.join(self.container_path, tmp_path)
                    metadata = read_metadata(dir_path)
                    #if metadata[X_OBJECT_TYPE] == DIR:
                    rmdirs(dir_path)
                    if '/' in tmp_path:
                        tmp_path = tmp_path.rsplit('/', 1)[0]
                    else:
                        break
                    
        self.metadata = {}
        self.data_file = None

        
                    
    def drop_cache(self, fd, offset, length):
        """Method for no-oping buffer cache drop method."""
        if not self.keep_cache:
            drop_buffer_cache(fd, offset, length)