From d6f184c345b49d95274f245c78d0a7976dcbc115 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Wed, 18 May 2016 15:38:47 +0200 Subject: [PATCH] generate_releases: expire by-hash files for all suites When setting suite.byhash to false, the suite's existing hashfiles need to be marked as unreferenced so they can be cleaned up. Signed-off-by: Julien Cristau --- dak/generate_releases.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dak/generate_releases.py b/dak/generate_releases.py index 34103f72..ae3577f3 100755 --- a/dak/generate_releases.py +++ b/dak/generate_releases.py @@ -362,12 +362,12 @@ class ReleaseWriter(object): out.close() os.rename(outfile + '.new', outfile) - if suite.byhash: - query = """ - UPDATE hashfile SET unreferenced = CURRENT_TIMESTAMP - WHERE suite_id = :id AND unreferenced IS NULL""" - session.execute(query, {'id': suite.suite_id}) + query = """ + UPDATE hashfile SET unreferenced = CURRENT_TIMESTAMP + WHERE suite_id = :id AND unreferenced IS NULL""" + session.execute(query, {'id': suite.suite_id}) + if suite.byhash: for filename in fileinfo: if not os.path.exists(filename): # probably an uncompressed index we didn't generate @@ -390,8 +390,9 @@ class ReleaseWriter(object): INSERT INTO hashfile (path, suite_id) VALUES (:p, :id)''', {'p': hashfile, 'id': suite.suite_id}) - session.commit() + session.commit() + if suite.byhash: for filename in fileinfo: if not os.path.exists(filename): # probably an uncompressed index we didn't generate -- 2.39.5