1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-17 18:50:11 +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 self.changed = False
def writeifchanged(self): def writeifchanged(self):
if self.changed: if not self.changed:
return
if not os.path.exists('stats'): if not os.path.exists('stats'):
os.mkdir('stats') os.mkdir('stats')
f = open(self.path, 'w')
lst = [] lst = []
for apk, app in self.apks.iteritems(): for apk, app in self.apks.iteritems():
appid, added = app appid, added = app
@ -1680,9 +1682,10 @@ class KnownApks:
if added: if added:
line += ' ' + time.strftime('%Y-%m-%d', added) line += ' ' + time.strftime('%Y-%m-%d', added)
lst.append(line) 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.