From: Ansgar Burchardt Date: Sun, 12 Aug 2012 06:45:30 +0000 (+0200) Subject: dak/clean_suites.py: allow limiting file removal to specific archives X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5f0ac77fc26ec8fb2d87775d79fc807d12face1;p=dak dak/clean_suites.py: allow limiting file removal to specific archives This allows us to remove all obsolete files from the NEW queue even when the maximum number of removals would be reached normally. --- diff --git a/dak/clean_suites.py b/dak/clean_suites.py index caa69709..e9360012 100755 --- a/dak/clean_suites.py +++ b/dak/clean_suites.py @@ -222,7 +222,7 @@ def clean_binaries(now_date, session): ######################################## -def clean(now_date, max_delete, session): +def clean(now_date, archives, max_delete, session): cnf = Config() count = 0 @@ -280,6 +280,10 @@ def clean(now_date, max_delete, session): old_files = old_files.limit(max_delete) print "Limiting removals to %d" % max_delete + if archives is not None: + archive_ids = [ a.archive_id for a in archives ] + old_files = old_files.filter(ArchiveFile.archive_id.in_(archive_ids)) + for af in old_files: filename = af.path if not os.path.exists(filename): @@ -445,6 +449,7 @@ def main(): cnf["Clean-Suites::Options::%s" % (i)] = "" Arguments = [('h',"help","Clean-Suites::Options::Help"), + ('a','archive','Clean-Suites::Options::Archive','HasArg'), ('n',"no-action","Clean-Suites::Options::No-Action"), ('m',"maximum","Clean-Suites::Options::Maximum", "HasArg")] @@ -469,6 +474,13 @@ def main(): session = DBConn().session() + archives = None + if 'Archive' in Options: + archive_names = Options['Archive'].split(',') + archives = session.query(Archive).filter(Archive.archive_name.in_(archive_names)).all() + if len(archives) == 0: + utils.fubar('Unknown archive.') + now_date = datetime.now() set_archive_delete_dates(now_date, session) @@ -477,7 +489,7 @@ def main(): clean_binaries(now_date, session) check_sources(now_date, session) check_files(now_date, session) - clean(now_date, max_delete, session) + clean(now_date, archives, max_delete, session) clean_maintainers(now_date, session) clean_fingerprints(now_date, session) clean_empty_directories(session)