mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-20 13:50:12 +01:00
rewritemeta: overwrite existing metadata only if no exception occurred
This commit is contained in:
parent
c45ef453fd
commit
5c3db9a7cc
@ -21,6 +21,8 @@ from argparse import ArgumentParser
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import io
|
import io
|
||||||
|
import tempfile
|
||||||
|
import shutil
|
||||||
|
|
||||||
from . import _
|
from . import _
|
||||||
from . import common
|
from . import common
|
||||||
@ -89,10 +91,12 @@ def main():
|
|||||||
newbuilds.append(new)
|
newbuilds.append(new)
|
||||||
app.builds = newbuilds
|
app.builds = newbuilds
|
||||||
|
|
||||||
try:
|
# rewrite to temporary file before overwriting existsing
|
||||||
metadata.write_metadata(path, app)
|
# file in case there's a bug in write_metadata
|
||||||
finally:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
pass
|
tmp_path = os.path.join(tmpdir, os.path.basename(path))
|
||||||
|
metadata.write_metadata(tmp_path, app)
|
||||||
|
shutil.move(tmp_path, path)
|
||||||
|
|
||||||
logging.debug(_("Finished"))
|
logging.debug(_("Finished"))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user