Move downloaded file into target location even across file system boundaries
This commit is contained in:
@@ -5,6 +5,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -611,7 +612,12 @@ def copy_url(
|
|||||||
|
|
||||||
log.info(f"{shorthand_uuid} Moving file to final location '{dest_path}' ...")
|
log.info(f"{shorthand_uuid} Moving file to final location '{dest_path}' ...")
|
||||||
try:
|
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_successful_download(section_name, config_obj, show, state_file_abs_path, job_uuid, shorthand_uuid)
|
||||||
log.info(f"{shorthand_uuid} Done moving")
|
log.info(f"{shorthand_uuid} Done moving")
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Reference in New Issue
Block a user