chiark / gitweb /
Fix update crash in case of unset dates in APK
authorDmitriy Bogdanov <di72nn@gmail.com>
Thu, 18 Feb 2016 12:40:51 +0000 (16:40 +0400)
committerDmitriy Bogdanov <di72nn@gmail.com>
Thu, 18 Feb 2016 12:40:51 +0000 (16:40 +0400)
fdroidserver/update.py

index aa9a9a3b12cf340366757c8d9ee528edaec84801..180ddcc90f4596a3952de4448992d617ca622bad 100644 (file)
@@ -568,12 +568,16 @@ def scan_apks(apps, apkcache, repodir, knownapks):
             # has to be more than 24 hours newer because ZIP/APK files do not
             # store timezone info
             manifest = apkzip.getinfo('AndroidManifest.xml')
-            dt_obj = datetime(*manifest.date_time)
-            checkdt = dt_obj - timedelta(1)
-            if datetime.today() < checkdt:
-                logging.warn('System clock is older than manifest in: '
-                             + apkfilename + '\nSet clock to that time using:\n'
-                             + 'sudo date -s "' + str(dt_obj) + '"')
+            if manifest.date_time[1] == 0:  # month can't be zero
+                logging.debug('AndroidManifest.xml has no date')
+            else:
+                dt_obj = datetime(*manifest.date_time)
+                checkdt = dt_obj - timedelta(1)
+                if datetime.today() < checkdt:
+                    logging.warn('System clock is older than manifest in: '
+                                 + apkfilename
+                                 + '\nSet clock to that time using:\n'
+                                 + 'sudo date -s "' + str(dt_obj) + '"')
 
             iconfilename = "%s.%s.png" % (
                 apk['id'],