1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-14 11:00:10 +01:00

Merge branch 'use_date_from_apk_in_known_apks' into 'master'

Pass a date from APK to KnownApks.recordapk()

... if --use-date-from-apks option is used.

Essentially, it just expands influence of `--use-date-from-apks` option to `stats/known_apks.txt`.

See merge request !141
This commit is contained in:
Ciaran Gultnieks 2016-07-13 11:43:33 +00:00
commit 21404e8622
2 changed files with 11 additions and 8 deletions

View File

@ -1570,9 +1570,11 @@ class KnownApks:
# Record an apk (if it's new, otherwise does nothing) # Record an apk (if it's new, otherwise does nothing)
# Returns the date it was added. # Returns the date it was added.
def recordapk(self, apk, app): def recordapk(self, apk, app, default_date=None):
if apk not in self.apks: if apk not in self.apks:
self.apks[apk] = (app, time.gmtime(time.time())) if default_date is None:
default_date = time.gmtime(time.time())
self.apks[apk] = (app, default_date)
self.changed = True self.changed = True
_, added = self.apks[apk] _, added = self.apks[apk]
return added return added

View File

@ -784,13 +784,14 @@ def scan_apks(apps, apkcache, repodir, knownapks, use_date_from_apk=False):
shutil.copyfile(baseline, shutil.copyfile(baseline,
os.path.join(get_icon_dir(repodir, '0'), iconfilename)) os.path.join(get_icon_dir(repodir, '0'), iconfilename))
# Record in known apks, getting the added date at the same time.. if use_date_from_apk and manifest.date_time[1] != 0:
added = knownapks.recordapk(apk['apkname'], apk['id']) default_date_param = datetime(*manifest.date_time).utctimetuple()
if added: else:
if use_date_from_apk and manifest.date_time[1] != 0: default_date_param = None
added = datetime(*manifest.date_time).timetuple()
logging.debug("Using date from APK")
# Record in known apks, getting the added date at the same time..
added = knownapks.recordapk(apk['apkname'], apk['id'], default_date=default_date_param)
if added:
apk['added'] = added apk['added'] = added
apkcache[apkfilename] = apk apkcache[apkfilename] = apk