Skip to content

Keep OnDeck movies in year folders out of move-back - #233

Merged
Brandon-Haney merged 1 commit into
StudioNirin:mainfrom
Brandon-Haney:pr/year-folder-moveback
Oct 22, 2026
Merged

Brandon-Haney merged 1 commit into
StudioNirin:mainfrom
Brandon-Haney:pr/year-folder-moveback

Conversation

@Brandon-Haney

Copy link
Copy Markdown
Collaborator

Fixes #232.

Movies stored in year folders (Film/2012/<movie>.mkv) went through move-back with no metadata match. The lookup used the cache path, but the OnDeck data is keyed by real path, so it fell back to guessing from folder names. That guess treats a numbers-only folder as a TV season, so a movie still on a user's OnDeck was read as "Film, season 2012" and queued to go back to the array. The later filter kept it, which was correct, but by then it had been logged as a restore and the run reported "1 file(s) failed to move to array" every time.

The same guess also gave every movie in those folders the name "Film", so as long as one of them was on someone's OnDeck or Watchlist, watched movies in the other year folders were never moved back.

Changes:

  • A cached file whose real path is on the current OnDeck or Watchlist is kept straight away, before any name matching.
  • Metadata is looked up by real path first, then cache path. When Plex says it's a movie, the season-folder rule and the TV filename patterns are skipped.
  • Anything the run is keeping on cache (OnDeck, Watchlist, pinned, and their sidecars) is dropped from the move-back list up front, so it isn't counted as a restore or a failed move.

Numbers-only season folders still work for date-based shows (Show/2012/Show - S2012E05.mkv), and there's a test for that.

Testing

  • tests/test_year_folder_moveback.py: OnDeck movie in a year folder is kept, a watched movie in another year folder is moved back, a known movie's name ignores the year folder, a date-based show is still read as TV, and files kept this run never reach the move-back lists.
  • With a movie library in year folders and a movie on OnDeck: the "failed to move to array" warning no longer appears, and watched movies in other year folders return to the array as expected.

Movies stored as Film/2012/<movie>.mkv had no metadata match during
move-back (lookups used the cache path, the OnDeck data is keyed by real
path), so the folder-name fallback read 2012 as a TV season. A movie still
on a user's OnDeck was queued to return to the array, kept by the later
filter, and reported as a failed move on every run. The same fallback gave
every movie in those folders the name "Film", so one OnDeck movie kept the
watched ones on cache.

- Keep a cached file whose real path is on the current OnDeck/Watchlist.
- Look up metadata by real path first; a known movie skips the season
  folder check and the TV regex.
- Drop anything this run keeps on cache (all_active_media) from the
  move-back lists, so it is not counted as a restore or a failed move.
@StudioNirin

Copy link
Copy Markdown
Owner

Does this fix add any other complications? From the sound of it, it happened because they used a weird non-standard naming convention for movies folder names. There shouldnt be movie files just loose inside a year folder, it should be...

Movies/2026/{moviename} (2026)/{moviename (2026).mkv}

Or i guess various variations depending on radarr settings, but i dont recall any that put all the films in a year folder loose like that.

I guess its fine, I just dont want to get into the habit of supporting all the weird badly-configured edge cases. That way madness lies.

I may be misunderstanding the entire issue though.

@Yusseiin

Copy link
Copy Markdown

Does this fix add any other complications? From the sound of it, it happened because they used a weird non-standard naming convention for movies folder names. There shouldnt be movie files just loose inside a year folder, it should be...

Movies/2026/{moviename} (2026)/{moviename (2026).mkv}

Or i guess various variations depending on radarr settings, but i dont recall any that put all the films in a year folder loose like that.

I guess its fine, I just dont want to get into the habit of supporting all the weird badly-configured edge cases. That way madness lies.

I may be misunderstanding the entire issue though.

It was my case, i am not using Radarr/Sonarr and my folder structure are
Movies/{years}/Movies of that years.mkv
This issue is happening with only 1 movie, but we all the rest are working fine.
This was the issue

@Brandon-Haney

Copy link
Copy Markdown
Collaborator Author

Fair concern, and I'm with you on not chasing every odd setup. This one turned out to be wider than the loose-files layout though. The fallback treats any numbers-only folder in the path as a TV season, so your example layout hits it too. With Movies/2026/Some Film (2026)/Some Film (2026).mkv, every movie under a year folder comes out as "Movies" when we compare names. So if one of them is on someone's OnDeck, all the watched ones in that tree look needed and never go back to the array. Yusseiin's loose files just made it visible, because there the guess went the other way and produced the warning.

So the fix isn't really a special case for year folders. It stops guessing from folder names when we already know the answer:

  • if the file's real path is on someone's OnDeck or Watchlist right now, it stays
  • the Plex metadata lookup uses the real path, which is how the OnDeck data is stored (it was using the cache path, so it almost never matched), and if Plex says it's a movie we skip the TV season rule
  • anything the run is already keeping on cache gets dropped from the move-back list before it's counted, which is the same check the later filter already did, just earlier

On complications: all three only ever make it keep a file it would otherwise have moved, or use better information for the decision. TV handling is unchanged, including date-based shows that use 2012 as a season folder, and there's a test for that. Worst case if something's off is a file stays on cache an extra run, not anything being moved or deleted that shouldn't be.

@Brandon-Haney
Brandon-Haney merged commit 9ffdffa into StudioNirin:main Oct 22, 2026
2 checks passed
@Brandon-Haney
Brandon-Haney deleted the pr/year-folder-moveback branch October 22, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Question/Help] WARNING - 1 file(s) failed to move to array

3 participants