]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blobdiff - www/webapp/backend/releases.py
Merge branch 'master' of ssh://git.ipfire.org/pub/git/ipfire.org
[people/shoehn/ipfire.org.git] / www / webapp / backend / releases.py
index de969db26414724297b6fc7043e51a54d0de2ca0..b03f21f695e08b3984355f7117d6838c4307c8cf 100644 (file)
@@ -59,6 +59,7 @@ class File(object):
                        "alix"          : 41,
                        "usbfdd"        : 31,
                        "usbhdd"        : 30,
+                       "arm"       : 40,
                        "xen"           : 50,
                }
                
@@ -94,6 +95,24 @@ class File(object):
        def filename(self):
                return self.__data.get("filename")
 
+       @property
+       def basename(self):
+               return os.path.basename(self.filename)
+
+       @property
+       def size(self):
+               return self.__data.get("filesize")
+
+       @property
+       def arch(self):
+               known_arches = ("i586", "arm")
+
+               for arch in known_arches:
+                       if arch in self.basename:
+                               return arch
+
+               return "N/A" 
+
 
 class Release(object):
        @property
@@ -117,7 +136,7 @@ class Release(object):
        def files(self):
                if not self.__files:
                        files = self.db.query("SELECT id FROM files WHERE releases = %s \
-                                       AND loadable = 'Y'", self.id)
+                                       AND loadable = 'Y' AND NOT filetype = 'torrent'", self.id)
 
                        self.__files = [File(self, f.id) for f in files]
                        self.__files.sort(lambda a, b: cmp(a.prio, b.prio))
@@ -159,7 +178,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()
 
@@ -182,6 +205,9 @@ class Release(object):
                if "usb-hdd" in filename:
                        return "usbhdd"
 
+               if "arm" in filename:
+                       return "arm"
+
                if "scon" in filename:
                        return "alix"
 
@@ -196,6 +222,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.