chiark / gitweb /
Revert "Switch to python-magic from PIL"
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 3 Feb 2014 22:04:33 +0000 (23:04 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 3 Feb 2014 22:04:33 +0000 (23:04 +0100)
This reverts commit 8541cdf8939cf63a5fa6a182b5ea34667b7201ea.

fdroidserver/common.py

index 17736029ad412be3855bb9c7c4db205b11e3a47a..40d7060ae5d1f6dc4a7235a20301faf2efc6fb1d 100644 (file)
@@ -1186,6 +1186,9 @@ def scan_source(build_dir, root_dir, thisbuild):
     scanignore = getpaths('scanignore')
     scandelete = getpaths('scandelete')
 
+    ms = magic.open(magic.MIME_TYPE)
+    ms.load()
+
     def toignore(fd):
         for i in scanignore:
             if fd.startswith(i):
@@ -1234,7 +1237,7 @@ def scan_source(build_dir, root_dir, thisbuild):
                 if suspect in curfile.lower():
                     handleproblem('usual supect', fd, fp)
 
-            mime = magic.from_file(fp, mime=True)
+            mime = ms.file(fp)
             if mime == 'application/x-sharedlib':
                 handleproblem('shared library', fd, fp)
             elif mime == 'application/x-archive':
@@ -1251,6 +1254,7 @@ def scan_source(build_dir, root_dir, thisbuild):
                     if 'DexClassLoader' in line:
                         handleproblem('DexClassLoader', fd, fp)
                         break
+    ms.close()
 
     # Presence of a jni directory without buildjni=yes might
     # indicate a problem (if it's not a problem, explicitly use