Move downloaded file into target location even across file system boundaries

This commit is contained in:
2022-03-20 02:22:12 +01:00
parent e78659b2de
commit b5dff485d9

View File

@@ -5,6 +5,7 @@ import logging
import os
import pathlib
import re
import shutil
import sys
import time
@@ -611,7 +612,12 @@ def copy_url(
log.info(f"{shorthand_uuid} Moving file to final location '{dest_path}' ...")
try:
os.rename(tmp_path, dest_path)
shutil.move(tmp_path, dest_path)
except OSError as ose:
log.error(f"{shorthand_uuid} Failed moving file with an OSError\n"
f"{ose}\n"
f"Other threads continue unhindered.")
else:
log_successful_download(section_name, config_obj, show, state_file_abs_path, job_uuid, shorthand_uuid)
log.info(f"{shorthand_uuid} Done moving")
except Exception: