1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-11 15:13:27 +02:00

Simlify known_apks writing

This commit is contained in:
Daniel Martí 2015-08-28 18:26:23 -07:00
parent 79749fe8b4
commit f4cbb6b3f8

View File

@ -1669,10 +1669,12 @@ class KnownApks:
self.changed = False
def writeifchanged(self):
if self.changed:
if not self.changed:
return
if not os.path.exists('stats'):
os.mkdir('stats')
f = open(self.path, 'w')
lst = []
for apk, app in self.apks.iteritems():
appid, added = app
@ -1680,9 +1682,10 @@ class KnownApks:
if added:
line += ' ' + time.strftime('%Y-%m-%d', added)
lst.append(line)
with open(self.path, 'w') as f:
for line in sorted(lst):
f.write(line + '\n')
f.close()
# Record an apk (if it's new, otherwise does nothing)
# Returns the date it was added.