another shutil update
This commit is contained in:
@@ -203,20 +203,19 @@ def process_single_file(
|
||||
else:
|
||||
# File successfully converted to av1, move to destination
|
||||
target_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
success = False
|
||||
|
||||
try:
|
||||
shutil.move(str(temp_path), str(target_path))
|
||||
except (PermissionError, OSError):
|
||||
try:
|
||||
logging.warning(f"Failed to move file with metadata, falling back to copy")
|
||||
shutil.copy(str(temp_path), str(target_path))
|
||||
# Use cp to copy file since it handles permissions better
|
||||
subprocess.run(["cp", str(temp_path), str(target_path)], check=True)
|
||||
temp_path.unlink()
|
||||
except Exception as e:
|
||||
success = True
|
||||
except subprocess.CalledProcessError as e:
|
||||
logging.error(f"Failed to copy file: {e}")
|
||||
if temp_path.exists():
|
||||
temp_path.unlink()
|
||||
release_file_lock(filepath)
|
||||
return False
|
||||
|
||||
if success:
|
||||
logging.info(f"Successfully compressed {filepath}")
|
||||
if remove_source:
|
||||
logging.info(f"Removing source file {filepath}")
|
||||
@@ -224,6 +223,9 @@ def process_single_file(
|
||||
release_file_lock(filepath)
|
||||
return True
|
||||
|
||||
release_file_lock(filepath)
|
||||
return False
|
||||
|
||||
def process_directory(
|
||||
*,
|
||||
source_dir: pathlib.Path,
|
||||
|
||||
Reference in New Issue
Block a user