Keep the newer cache copy when Move to Array finds an older array copy - #222
Merged
Brandon-Haney merged 1 commit intoOct 2, 2026
Merged
Conversation
Move to Array restored the .plexcached backup or kept the same-name array file whenever one existed, and deleted the cache copy without comparing them. When the cache copy is newer (a Sonarr/Radarr upgrade or a Tdarr pass), the old version was kept and the new one removed. It now follows the same rule as the caching run's in-place upgrade check: an array copy of the same size is restored as before, otherwise the cache version is copied to a partial name, verified, renamed into place, and only then are the old backup and the cache copy removed. A copy that fails or comes out the wrong size leaves both versions where they were. Both the sequential and parallel paths share one helper.
StudioNirin
approved these changes
Oct 2, 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.
Move to Array in Maintenance → Untracked Files handled files marked Has backup or Has copy by restoring the array version and deleting the cache copy. It only checked that the array file existed, not whether it matched. When the cache copy is the newer one (a Sonarr/Radarr in-place upgrade, or a Tdarr pass as described in #221), the old version was kept and the new one removed.
The caching run already handles this case: when restoring a watched file whose cache copy differs in size from its backup, it treats it as an in-place upgrade and copies the cache version across. This brings Move to Array in line with that rule.
Change
.plexcachedbackup or the same-name file), it is restored as before and the cache copy is deleted. No copy needed..pc-partname next to the target, the size is verified, it is renamed into place, and only then are the old backup and the cache copy removed. A copy that fails or comes out the wrong size leaves both versions where they were._sync_one_to_array) instead of two copies of the same logic.This also covers a smaller case in the "Cache only" path: a copy that came out the wrong size used to leave the truncated file on the array under the real filename. It now only ever lands under the partial name.
Tests
tests/test_sync_to_array_newer_cache.py: real files, sequential and parallel paths, cache copy newer than the backup / array copy, and the identical fast paths.tests/test_maintenance_service.py: the existingTestSyncToArraycases now use real files, plus a copy that fails part-way over an older backup.How to test
.plexcachedbackup on the array (or the same-name file on the array)..plexcachedbackup is gone, and the cache copy is removed.