mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-15 15:32:30 +03:00
Simlify known_apks writing
This commit is contained in:
parent
79749fe8b4
commit
f4cbb6b3f8
1 changed files with 15 additions and 12 deletions
|
@ -1669,20 +1669,23 @@ class KnownApks:
|
|||
self.changed = False
|
||||
|
||||
def writeifchanged(self):
|
||||
if self.changed:
|
||||
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
|
||||
line = apk + ' ' + appid
|
||||
if added:
|
||||
line += ' ' + time.strftime('%Y-%m-%d', added)
|
||||
lst.append(line)
|
||||
if not self.changed:
|
||||
return
|
||||
|
||||
if not os.path.exists('stats'):
|
||||
os.mkdir('stats')
|
||||
|
||||
lst = []
|
||||
for apk, app in self.apks.iteritems():
|
||||
appid, added = app
|
||||
line = apk + ' ' + appid
|
||||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue