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,20 +1669,23 @@ class KnownApks:
self.changed = False self.changed = False
def writeifchanged(self): def writeifchanged(self):
if self.changed: if not self.changed:
if not os.path.exists('stats'): return
os.mkdir('stats')
f = open(self.path, 'w') if not os.path.exists('stats'):
lst = [] os.mkdir('stats')
for apk, app in self.apks.iteritems():
appid, added = app lst = []
line = apk + ' ' + appid for apk, app in self.apks.iteritems():
if added: appid, added = app
line += ' ' + time.strftime('%Y-%m-%d', added) line = apk + ' ' + appid
lst.append(line) if added:
line += ' ' + time.strftime('%Y-%m-%d', added)
lst.append(line)
with open(self.path, 'w') as f:
for line in sorted(lst): for line in sorted(lst):
f.write(line + '\n') f.write(line + '\n')
f.close()
# 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.