예제 #1
0
 def __init__(self, path, drive, account, container, logger,
              uid=DEFAULT_UID, gid=DEFAULT_GID):
     self.root = path
     if container:
         self.container = container
     else:
         self.container = None
     if self.container:
         self.datadir = os.path.join(path, drive, self.container)
     else:
         self.datadir = os.path.join(path, drive)
     self.account = account
     assert logger is not None
     self.logger = logger
     self.metadata = {}
     self.container_info = None
     self.object_info = None
     self.uid = int(uid)
     self.gid = int(gid)
     self.db_file = _db_file
     self.dir_exists = os.path.exists(self.datadir)
     if self.dir_exists:
         try:
             self.metadata = _read_metadata(self.datadir)
         except EOFError:
             create_container_metadata(self.datadir)
     else:
         return
     if self.container:
         if not self.metadata:
             create_container_metadata(self.datadir)
             self.metadata = _read_metadata(self.datadir)
         else:
             if not validate_container(self.metadata):
                 create_container_metadata(self.datadir)
                 self.metadata = _read_metadata(self.datadir)
     else:
         if not self.metadata:
             create_account_metadata(self.datadir)
             self.metadata = _read_metadata(self.datadir)
         else:
             if not validate_account(self.metadata):
                 create_account_metadata(self.datadir)
                 self.metadata = _read_metadata(self.datadir)
예제 #2
0
 def __init__(self, path, drive, account, container, logger,
              uid=DEFAULT_UID, gid=DEFAULT_GID):
     self.root = path
     
     self.datadir = os.path.join(path, drive)
     
     self.account = account
     assert logger is not None
     self.logger = logger
     self.metadata = {}
     self.container_info = None
     self.object_info = None
     self.uid = int(uid)
     self.gid = int(gid)
     self.db_file = _db_file
     self.dir_exists = os.path.exists(self.datadir)
     
     self.metauuid = 'ff89f933b2ca8df40'
     self.fhr_path = parent_path(self.datadir)
     
     self.metafile = os.path.join(path, self.metauuid,drive)
     self.meta_fhr_path = parent_path(self.metafile) 
         
     if self.meta_fhr_dir_is_deleted():
         self.create_dir_object(self.meta_fhr_path)
         
     if not os.path.exists(self.datadir):
         return
     if self.dir_exists:
         self.metadata = meta_read_metadata(self.metafile)    
     else:
         return
     
     if not self.metadata:
         meta_create_account_metadata(self.datadir,self.metafile)
         self.metadata = meta_read_metadata(self.metafile)
     else:
         if not validate_account(self.metadata):
             meta_create_account_metadata(self.datadir,self.metafile)
             self.metadata = meta_read_metadata(self.metafile)