chiark / gitweb /
Don't crash if a magic number can't be used
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 22 Jul 2014 08:06:38 +0000 (10:06 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 22 Jul 2014 08:06:51 +0000 (10:06 +0200)
This should fix the anki build crashing.

fdroidserver/common.py

index 960d06ca02f970cb08ddb6d7b355893e1530503d..18148018f4e3fa8a040ca2b3df83662d17c981f3 100644 (file)
@@ -1460,7 +1460,10 @@ def scan_source(build_dir, root_dir, thisbuild):
             if toignore(fd):
                 continue
 
-            mime = magic.from_file(fp, mime=True) if ms is None else ms.file(fp)
+            try:
+                mime = magic.from_file(fp, mime=True) if ms is None else ms.file(fp)
+            except UnicodeError:
+                warnproblem('malformed magic number', fd, fp)
 
             if mime == 'application/x-sharedlib':
                 count += handleproblem('shared library', fd, fp)