Fix iCloud Drive re-optimisation bug#71
Merged
alin23 merged 1 commit intoFuzzyIdeas:mainfrom Feb 10, 2026
Merged
Conversation
When OptimisedFileBehaviour is sameFolder, process() copies the original to a new -optimised path but never marks the original with an xattr. When iCloud's bird daemon syncs the new file and generates fresh FSEvents on the original, it passes all checks again and gets re-optimised, creating duplicate "-optimised 2" files. - Mark original file with xattr after copy to prevent re-trigger - Add configurable protection window setting (default 3s) so users on iCloud Drive can increase it to handle longer sync times - Clean up newPath from alreadyOptimisedFiles to fix memory leak - Add protection window picker in General > Optimisation settings - Include new setting in SETTINGS_TO_SYNC for iCloud sync Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-optimisedpath, preventing iCloud sync FSEvents from re-triggering optimisation on the originaloptimisedFileProtectionMs) defaulting to 3s — users on iCloud Drive can increase to 30s/60s to handle longer sync timesnewPathwas inserted intoalreadyOptimisedFilesbut never cleaned upSETTINGS_TO_SYNCso it syncs across Macs via iCloudRoot Cause
When
OptimisedFileBehaviourissameFolder(orspecificFolder),process()copies the original to a new-optimisedpath and optimises the copy. The original file was never marked with an xattr, so when iCloud Drive'sbirddaemon syncs the new file and generates fresh FSEvents (.itemModified/.itemRenamed) on the original, it passes all checks again and gets re-optimised — creating duplicate-optimised 2.pngfiles from iCloud conflict renames.Changed Files
Clop/ClopApp.swiftoldPathwith xattr, use configurable TTL, addnewPathcleanupClop/Settings.swiftoptimisedFileProtectionMskey (default 3000ms) + add toSETTINGS_TO_SYNCClop/SettingsView.swiftTest plan
%f-optimised-optimisedfile is created, no " 2" duplicatesxattr -l <original>should showclop.optimisation.status🤖 Generated with Claude Code