[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] Re-use old by-hash file if new file hash matches



Force the file to have the same mtime if the checksum shows that it was
not changed.
---
 dak/generate_releases.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/dak/generate_releases.py b/dak/generate_releases.py
index 613c972..0c106b4 100755
--- a/dak/generate_releases.py
+++ b/dak/generate_releases.py
@@ -234,6 +234,16 @@ class ReleaseWriter(object):
             for h in hashes:
                 field = h.release_field
                 hashfile = os.path.join(os.path.dirname(filename), 'by-hash', field, fileinfo[filename][field])
+
+                # if the hash is known to exist, re-use the old file
+                if os.path.exists(hashfile):
+                    os.unlink(filename)
+                    os.link(hashfile, filename)
+                    break
+
+            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:
-- 
2.1.4



Reply to: