Beispiel #1
0
    def walk_filesystem(self):
        candidates = {}
        rootpath = utils.from_unicode(self.ROOTPATH)
        for dirpath, dirnames, files in os.walk(rootpath):
            try:
                dirpath = utils.to_unicode(dirpath)
            except UnicodeDecodeError as e:
                continue
            rel_dirpath = os.path.relpath(dirpath, start=self.ROOTPATH)
            logger.debug("'%s' '%s'" % (dirpath, rel_dirpath))
            if rel_dirpath != '.':
                objname = utils.to_standard_sep(rel_dirpath)
                candidates[objname] = self.none_info()
            for filename in files:
                try:
                    filename = utils.to_unicode(filename)
                except UnicodeDecodeError as e:
                    continue
                if rel_dirpath == '.':
                    prefix = ""
                else:
                    prefix = utils.to_standard_sep(rel_dirpath)
                objname = utils.join_objname(prefix, filename)
                candidates[objname] = self.none_info()

        db_cands = dict((name, self.none_info()) for name in self.list_files())
        candidates.update(db_cands)
        logger.debug("Candidates: %s" % candidates)
        return candidates
Beispiel #2
0
    def walk_filesystem(self):
        candidates = {}
        rootpath = utils.from_unicode(self.ROOTPATH)
        for dirpath, dirnames, files in os.walk(rootpath):
            try:
                dirpath = utils.to_unicode(dirpath)
            except UnicodeDecodeError as e:
                continue
            rel_dirpath = os.path.relpath(dirpath, start=self.ROOTPATH)
            logger.debug("'%s' '%s'" % (dirpath, rel_dirpath))
            if rel_dirpath != ".":
                objname = utils.to_standard_sep(rel_dirpath)
                candidates[objname] = self.none_info()
            for filename in files:
                try:
                    filename = utils.to_unicode(filename)
                except UnicodeDecodeError as e:
                    continue
                if rel_dirpath == ".":
                    prefix = ""
                else:
                    prefix = utils.to_standard_sep(rel_dirpath)
                objname = utils.join_objname(prefix, filename)
                candidates[objname] = self.none_info()

        db_cands = dict((name, self.none_info()) for name in self.list_files())
        candidates.update(db_cands)
        logger.debug("Candidates: %s" % candidates)
        return candidates
Beispiel #3
0
 def get_dir_contents(self, archive, objname):
     Q = ("select objname from archives where archive = ? and info != '{}'"
          " and objname like ?")
     c = self.db.execute(Q, (archive, utils.join_objname(objname, '%')))
     fetchone = c.fetchone
     while True:
         r = fetchone()
         if not r:
             break
         yield r[0]
Beispiel #4
0
 def _move_object(self, objname, etag, del_name):
     container = self.endpoint.container
     dest = common.OBJECT_DIRSEP + utils.join_objname(container, del_name)
     try:
         self.endpoint.object_move(objname,
                                   destination=dest,
                                   if_etag_match=etag)
     except ClientError as e:
         if e.status == 404:
             logger.warning("Upstream '%s' not found; already moved?" %
                            objname)
         else:
             raise
Beispiel #5
0
 def _move_object(self, objname, etag, del_name):
     container = self.endpoint.container
     dest = common.OBJECT_DIRSEP + utils.join_objname(container, del_name)
     try:
         self.endpoint.object_move(
             objname,
             destination=dest,
             if_etag_match=etag)
     except ClientError as e:
         if e.status == 404:
             logger.warning("Upstream '%s' not found; already moved?"
                            % objname)
         else:
             raise