mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03:00
keep yaml metadata when rewrite failed
This commit is contained in:
parent
cb131b45ab
commit
08acb55897
2 changed files with 13 additions and 13 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue