]> git.decadent.org.uk Git - dak.git/commitdiff
generate shasums if necessary due to old changes format
authorMark Hymers <mhy@debian.org>
Sun, 15 Nov 2009 17:28:03 +0000 (17:28 +0000)
committerMark Hymers <mhy@debian.org>
Sun, 15 Nov 2009 17:28:03 +0000 (17:28 +0000)
Signed-off-by: Mark Hymers <mhy@debian.org>
dak/import_new_files.py

index 253e656d4b17f2eb3e02c6aa3d1abf21afb6827b..8e1958b5146cdd94e571c6a45fe8df4936d44920 100755 (executable)
@@ -86,15 +86,27 @@ class ImportNewFiles(object):
 
                 files=[]
                 for chg_fn in u.pkg.files.keys():
+                    f = open(chg_fn)
                     cpf = ChangePendingFile()
                     cpf.filename = chg_fn
                     cpf.size = u.pkg.files[chg_fn]['size']
                     cpf.md5sum = u.pkg.files[chg_fn]['md5sum']
-                    cpf.sha1sum = u.pkg.files[chg_fn]['sha1sum']
-                    cpf.sha256sum = u.pkg.files[chg_fn]['sha256sum']
+
+                    if u.pkg.files[chg_fn].has_key('sha1sum'):
+                        cpf.sha1sum = u.pkg.files[chg_fn]['sha1sum']
+                    else:
+                        log.warning("Having to generate sha1sum for %s" % chg_fn)
+                        cpf.sha1sum = apt_pkg.sha1sum(f)
+
+                    if u.pkg.files[chg_fn].has_key('sha256sum'):
+                        cpf.sha256sum = u.pkg.files[chg_fn]['sha256sum']
+                    else:
+                        log.warning("Having to generate sha256sum for %s" % chg_fn)
+                        cpf.sha256sum = apt_pkg.sha256sum(f)
 
                     session.add(cpf)
                     files.append(cpf)
+                    f.close()
 
                 chg.files = files