Repository navigation
fix: skip re-import when the library file is already up to date - #29
Merged
Merged
Conversation
Cover the re-import behaviour of a completed torrent: when the episode is already present in the library as the same hardlink, importing again must not recreate (touch) the library file.
Importing was not idempotent: every pipeline run unconditionally deleted and recreated the library file, touching it and making the media server rescan and regenerate trickplay/chapter images on each pass. Skip the delete+relink when the destination is already the same hardlink (matching inode and device), or an identical-size copy when hardlinks are disabled, and mark the file processed so the torrent still moves on.
Owner
|
Good job.. it honestly wasn't a problem until I added alternative cuts.. but yeah I just added PIPELINE_FORCE_REIMPORT_EXISTING to force reimporting anyways (it's useful for currupted files, or for testing) |
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.
Problem
Importing a completed torrent is not idempotent: every pipeline run deletes the existing library file and re-links/copies it, which touches it and makes the media server rescan and regenerate trickplay/chapter images on each pass.
Fix
Short-circuit the delete+relink when the destination is already present:
The file is still marked processed, so the torrent moves to the completed category as before.
Test
I added this test based on the structure I noticed in other places.
Adds
src/torrent/torrent.controller.test.ts, which drives the real import path: an already-imported episode must not be re-created (ctimeunchanged, metadata not re-updated). It fails onmainbefore this change and passes after.