Skip to content

Commit df7c1c4

Browse files
teh-hippoCopilot
andcommitted
fix: guard autodelete for files referenced by multiple assets
When auto-delete tries to remove a file, check if other iCloud assets still reference the same path in the manifest. If so, skip deletion to prevent data loss during dedup migration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dce7f25 commit df7c1c4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/icloudpd/autodelete.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ def autodelete_photos(
113113
)
114114
for path in paths:
115115
if os.path.exists(path):
116+
if manifest is not None and not path.endswith(".xmp"):
117+
rel_path = os.path.relpath(path, directory)
118+
# Guard: don't delete files shared by multiple assets
119+
if manifest.count_by_path(rel_path) > 1:
120+
logger.debug(
121+
"Keeping %s — other assets still reference it",
122+
path,
123+
)
124+
continue
116125
logger.debug("Deleting %s...", path)
117126
delete_local = delete_file_dry_run if dry_run else delete_file
118127
if delete_local(logger, path) and manifest is not None and not path.endswith(".xmp"):

0 commit comments

Comments
 (0)