1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-03 17:50:11 +02:00

mirror: make _run_wget() return to the dir it started in

This kind of function should not change the working environment, especially
since so much of the fdroidserver code assumes the current working directory
is the root of an fdroid repo.

It is used in fdroidserver/mirror.py with absolute paths always, so it
shouldn't change any existing use.  I found this issue by using it in a
plugin.
This commit is contained in:
Hans-Christoph Steiner 2021-11-29 12:18:43 +01:00
parent 319bf47a6b
commit c54f9ea4ca

View File

@ -27,6 +27,7 @@ def _run_wget(path, urls):
if not urls:
return
logging.debug(_('Running wget in {path}').format(path=path))
cwd = os.getcwd()
os.makedirs(path, exist_ok=True)
os.chdir(path)
urls_file = '.fdroid-mirror-wget-input-file'
@ -43,6 +44,7 @@ def _run_wget(path, urls):
]
)
os.remove(urls_file)
os.chdir(cwd) # leave the working env the way we found it
def main():