mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 06:50: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}')
|
warn_or_exception(_('Cannot write "{path}", not an accepted format, use: {formats}')
|
||||||
.format(path=metadatapath, formats=', '.join(accepted)))
|
.format(path=metadatapath, formats=', '.join(accepted)))
|
||||||
|
|
||||||
try:
|
with open(metadatapath, 'w') as mf:
|
||||||
with open(metadatapath, 'w') as mf:
|
if ext == 'txt':
|
||||||
if ext == 'txt':
|
return write_txt(mf, app)
|
||||||
return write_txt(mf, app)
|
elif ext == 'yml':
|
||||||
elif ext == 'yml':
|
return write_yaml(mf, app)
|
||||||
return write_yaml(mf, app)
|
|
||||||
except FDroidException as e:
|
|
||||||
os.remove(metadatapath)
|
|
||||||
raise e
|
|
||||||
|
|
||||||
warn_or_exception(_('Unknown metadata format: %s') % metadatapath)
|
warn_or_exception(_('Unknown metadata format: %s') % metadatapath)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,10 +108,14 @@ def main():
|
||||||
newbuilds.append(new)
|
newbuilds.append(new)
|
||||||
app.builds = newbuilds
|
app.builds = newbuilds
|
||||||
|
|
||||||
metadata.write_metadata(base + '.' + to_ext, app)
|
try:
|
||||||
|
metadata.write_metadata(base + '.' + to_ext, app)
|
||||||
if ext != to_ext:
|
# remove old format metadata if there was a format change
|
||||||
os.remove(path)
|
# and rewriting to the new format worked
|
||||||
|
if ext != to_ext:
|
||||||
|
os.remove(path)
|
||||||
|
finally:
|
||||||
|
pass
|
||||||
|
|
||||||
logging.debug(_("Finished"))
|
logging.debug(_("Finished"))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue