Skip to content

Commit

Permalink
Copy failed images
Browse files Browse the repository at this point in the history
  • Loading branch information
marySalvi committed Oct 7, 2024
1 parent aa246d2 commit 37bc866
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion imagedephi/redact/redact.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from enum import Enum
import importlib.resources
from pathlib import Path
from shutil import copy2
from typing import NamedTuple

import tifftools
Expand Down Expand Up @@ -158,7 +159,9 @@ def redact_images(
if not redaction_plan.is_comprehensive():
logger.info(f"Redaction could not be performed for {image_file.name}.")
failed_file = failed_dir / image_file.name
failed_file.hardlink_to(image_file)
# Using copy2 preserves metadata
# https://docs.python.org/3/library/shutil.html#shutil.copy2
copy2(image_file, failed_file)
failed_img_counter += 1
with open(failed_manifest_file, "a") as manifest:
manifest.write(f" - {image_file.name}: \n missing_tags: \n")
Expand Down

0 comments on commit 37bc866

Please sign in to comment.