]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blobdiff - www/webapp/backend/releases.py
Fix hashing of big files.
[people/shoehn/ipfire.org.git] / www / webapp / backend / releases.py
index de969db26414724297b6fc7043e51a54d0de2ca0..7ce641d7e277e4ce77e38cfb5c7c22f14f3deb71 100644 (file)
@@ -94,6 +94,10 @@ class File(object):
        def filename(self):
                return self.__data.get("filename")
 
+       @property
+       def basename(self):
+               return os.path.basename(self.filename)
+
 
 class Release(object):
        @property
@@ -159,7 +163,11 @@ class Release(object):
                sha1 = hashlib.sha1()
 
                with open(filename) as f:
-                       sha1.update(f.read())
+                       buf_size = 1024
+                       buf = f.read(buf_size)
+                       while buf:
+                               sha1.update(buf)
+                               buf = f.read(buf_size)
 
                return sha1.hexdigest()
 
@@ -196,6 +204,9 @@ class Release(object):
 
                path = os.path.join(basepath, self.path)
 
+               if not os.path.exists(path):
+                       return
+
                files = [f.filename for f in self.files]
 
                # Make files that do not exists not loadable.