예제 #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
예제 #2
0
파일: server.py 프로젝트: vbellur/UFO
 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
예제 #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
예제 #4
0
 def unlink(self):
     """
     Remove directory/container if empty.
     """
     if dir_empty(self.datadir):
         rmdirs(self.datadir)
예제 #5
0
파일: server.py 프로젝트: vbellur/UFO
                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)