Repository navigation
Leave both copies alone when the array copy is newer than the cache copy - #226
Merged
Brandon-Haney merged 1 commit intoOct 6, 2026
Merged
Conversation
Move to Array keeps the cache copy whenever it differs in size from the array copy, which is right when a tool rewrote the cache side. When a tool rewrote the array side directly, the cache copy is the stale one and was copied over the newer array file. Caching keeps the original modification time on both sides, so an untouched pair has matching mtimes and whichever side was rewritten is newer. If the array copy (same-name file or .plexcached backup) is newer than the cache copy by more than 2 seconds, the file is skipped and reported for review with both copies left in place. Matching mtimes keep the existing behaviour.
StudioNirin
approved these changes
Oct 6, 2026
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.
Follow-up to #222, from @DeLo1585's point on #221.
#222 made Move to Array keep the cache copy whenever it differs in size from the array copy, which is right when a tool rewrote the cache side (a Sonarr/Radarr in-place upgrade, a Tdarr pass through
/mnt/user). When a tool rewrote the array side directly, the cache copy is the stale one, and Move to Array copied it over the newer array file.Change
Caching keeps the original modification time on both sides: the cache copy is written with
copystat, and the.plexcachedbackup is a rename of the original. So an untouched pair has matching mtimes, and whichever side a tool rewrote ends up newer..plexcachedbackup) is newer than the cache copy by more than 2 seconds, Move to Array skips that file and reports "Array copy is newer than the cache copy, left both in place for review". Nothing is copied, renamed or deleted.Tests
tests/test_sync_to_array_newer_cache.pygains 10 cases (sequential and parallel): a newer same-name array file and a newer backup are both left untouched, a newer cache copy still replaces the array copy, and same-mtime / within-tolerance pairs keep the cache version. Without the guard, the four "array copy is newer" cases fail.How to test
.plexcachedbackup on the array.touchit so it is newer than the cache copy.