mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-08-15 19:00:11 +02:00
keep yaml metadata when rewrite failed
This commit is contained in:
parent
cb131b45ab
commit
08acb55897
@ -1584,15 +1584,11 @@ def write_metadata(metadatapath, app):
|
||||
warn_or_exception(_('Cannot write "{path}", not an accepted format, use: {formats}')
|
||||
.format(path=metadatapath, formats=', '.join(accepted)))
|
||||
|
||||
try:
|
||||
with open(metadatapath, 'w') as mf:
|
||||
if ext == 'txt':
|
||||
return write_txt(mf, app)
|
||||
elif ext == 'yml':
|
||||
return write_yaml(mf, app)
|
||||
except FDroidException as e:
|
||||
os.remove(metadatapath)
|
||||
raise e
|
||||
with open(metadatapath, 'w') as mf:
|
||||
if ext == 'txt':
|
||||
return write_txt(mf, app)
|
||||
elif ext == 'yml':
|
||||
return write_yaml(mf, app)
|
||||
|
||||
warn_or_exception(_('Unknown metadata format: %s') % metadatapath)
|
||||
|
||||
|
@ -108,10 +108,14 @@ def main():
|
||||
newbuilds.append(new)
|
||||
app.builds = newbuilds
|
||||
|
||||
metadata.write_metadata(base + '.' + to_ext, app)
|
||||
|
||||
if ext != to_ext:
|
||||
os.remove(path)
|
||||
try:
|
||||
metadata.write_metadata(base + '.' + to_ext, app)
|
||||
# remove old format metadata if there was a format change
|
||||
# and rewriting to the new format worked
|
||||
if ext != to_ext:
|
||||
os.remove(path)
|
||||
finally:
|
||||
pass
|
||||
|
||||
logging.debug(_("Finished"))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user