]> git.decadent.org.uk Git - dak.git/commitdiff
generate_releases: expire by-hash files for all suites
authorJulien Cristau <jcristau@debian.org>
Wed, 18 May 2016 13:38:47 +0000 (15:38 +0200)
committerJulien Cristau <jcristau@debian.org>
Wed, 18 May 2016 13:55:14 +0000 (15:55 +0200)
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 <jcristau@debian.org>
dak/generate_releases.py

index 34103f72b4defb2ea6f2363e318b8f435fc5833c..ae3577f3db998d17e7cad6837e58673aa113bcc8 100755 (executable)
@@ -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