]> git.decadent.org.uk Git - dak.git/commitdiff
generate_releases: separate hashfile table update from hardlink creation
authorJulien Cristau <jcristau@debian.org>
Wed, 18 May 2016 13:33:07 +0000 (15:33 +0200)
committerJulien Cristau <jcristau@debian.org>
Wed, 18 May 2016 13:55:14 +0000 (15:55 +0200)
This way we only touch the filesystem after the db is updated.

Signed-off-by: Julien Cristau <jcristau@debian.org>
dak/generate_releases.py

index d947def8a3cca2a886bc9e9db11f6679459207cf..34103f72b4defb2ea6f2363e318b8f435fc5833c 100755 (executable)
@@ -390,7 +390,16 @@ class ReleaseWriter(object):
                             INSERT INTO hashfile (path, suite_id)
                             VALUES (:p, :id)''',
                             {'p': hashfile, 'id': suite.suite_id})
+            session.commit()
 
+            for filename in fileinfo:
+                if not os.path.exists(filename):
+                    # probably an uncompressed index we didn't generate
+                    continue
+
+                for h in hashes:
+                    field = h.release_field
+                    hashfile = os.path.join(os.path.dirname(filename), 'by-hash', field, fileinfo[filename][field])
                     try:
                         os.makedirs(os.path.dirname(hashfile))
                     except OSError as exc:
@@ -402,7 +411,6 @@ class ReleaseWriter(object):
                         if exc.errno != errno.EEXIST:
                             raise
 
-                session.commit()
 
         sign_release_dir(suite, os.path.dirname(outfile))