Changeset - 95c38de476a7
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2013-02-19 19:48:45
marcin@python-works.com
cleanup would recurse into every leaf and could thus not be used on lots of
large repositories.
1 file changed with 8 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/paster_commands/cleanup.py
Show inline comments
 
@@ -76,28 +76,35 @@ class Command(BasePasterCommand):
 
        :param name:
 
        """
 
        date_part = name[4:19]  # 4:19 since we don't parse milisecods
 
        return datetime.datetime.strptime(date_part, '%Y%m%d_%H%M%S')
 

	
 
    def command(self):
 
        #get SqlAlchemy session
 
        self._init_session()
 

	
 
        repos_location = RhodeCodeUi.get_repos_location()
 
        to_remove = []
 
        for dn, dirs, f in os.walk(safe_str(repos_location)):
 
            for loc in dirs:
 
            alldirs = list(dirs)
 
            del dirs[:]
 
            if ('.hg' in alldirs or
 
                'objects' in alldirs and ('refs' in alldirs or 'packed-refs' in f)):
 
                continue
 
            for loc in alldirs:
 
                if REMOVED_REPO_PAT.match(loc):
 
                    to_remove.append([os.path.join(dn, loc),
 
                                      self._extract_date(loc)])
 
                else:
 
                    dirs.append(loc)
 

	
 
        #filter older than (if present)!
 
        now = datetime.datetime.now()
 
        older_than = self.options.older_than
 
        if older_than:
 
            to_remove_filtered = []
 
            older_than_date = self._parse_older_than(older_than)
 
            for name, date_ in to_remove:
 
                repo_age = now - date_
 
                if repo_age > older_than_date:
 
                    to_remove_filtered.append([name, date_])
 

	
0 comments (0 inline, 0 general)