From a6da4a4a989b47a1e36c22dbf2a4445a381714d1 Mon Sep 17 00:00:00 2001 From: Silo Server Developer Date: Wed, 27 May 2026 18:47:02 +0200 Subject: [PATCH] test(naming): document bare-id trade-off; cover CJK title + movies numeric Co-Authored-By: Claude Opus 4.7 (1M context) --- internal/naming/folderid.go | 3 +++ internal/naming/folderid_numeric_test.go | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/internal/naming/folderid.go b/internal/naming/folderid.go index ade90a1c..e9cc064c 100644 --- a/internal/naming/folderid.go +++ b/internal/naming/folderid.go @@ -69,6 +69,9 @@ func ParseFolderIDs(folderName string, folderType string) *FolderIDHints { // A bare trailing number is only an ID when appended to a real title. If the // name has no letters (e.g. "86", "22 7"), it's a numeric title, not an ID. + // Trade-off: a folder named ONLY a bare provider id (e.g. "81189") with no + // title text now returns nil rather than that id — acceptable because + // Sonarr/Radarr never produce bare-number folders. if !containsLetter(trimmed) { return nil } diff --git a/internal/naming/folderid_numeric_test.go b/internal/naming/folderid_numeric_test.go index a50a71a9..5e0e61be 100644 --- a/internal/naming/folderid_numeric_test.go +++ b/internal/naming/folderid_numeric_test.go @@ -22,4 +22,16 @@ func TestParseFolderIDs_NumericTitleIsNotAnID(t *testing.T) { if got == nil || got.TmdbID != "27205" { t.Errorf(`ParseFolderIDs("{tmdb-27205}","movies") = %+v, want TmdbID="27205"`, got) } + + // Non-Latin (CJK) title with a trailing real id must still parse — + // unicode.IsLetter covers kana/kanji, so this is treated as title + id. + got = ParseFolderIDs("進撃の巨人 73743", "series") + if got == nil || got.TvdbID != "73743" { + t.Errorf(`ParseFolderIDs("進撃の巨人 73743","series") = %+v, want TvdbID="73743"`, got) + } + + // Numeric-only title for a movies library is also not an id. + if got := ParseFolderIDs("86", "movies"); got != nil { + t.Errorf(`ParseFolderIDs("86","movies") = %+v, want nil`, got) + } }