From ac81733cbc527d4e1d5b7da7d6e606c9dc0dd8b6 Mon Sep 17 00:00:00 2001 From: Mikal Stordal Date: Sun, 20 Oct 2024 09:09:42 +0200 Subject: [PATCH] fix: hide files in import limbo (again) - Hide files in "import limbo" from the unrecognized files option again, but this time properly add new include options to the monolithic file endpoint to include them separately. They're hidden/excluded by default but can be included if needed. --- Shoko.Server/API/v3/Controllers/FileController.cs | 1 + Shoko.Server/API/v3/Helpers/ModelHelper.cs | 8 +++++--- Shoko.Server/API/v3/Models/Common/FileIncludeTypes.cs | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Shoko.Server/API/v3/Controllers/FileController.cs b/Shoko.Server/API/v3/Controllers/FileController.cs index 08bfca5d6..e117f6337 100644 --- a/Shoko.Server/API/v3/Controllers/FileController.cs +++ b/Shoko.Server/API/v3/Controllers/FileController.cs @@ -1471,6 +1471,7 @@ public ActionResult> RegexSearchByFileName([FromRoute] string path) /// Page number. /// Set to false to exclude series and episode cross-references. /// + [Obsolete("Use the universal file endpoint instead.")] [HttpGet("MissingCrossReferenceData")] public ActionResult> GetFilesWithMissingCrossReferenceData( [FromQuery, Range(0, 1000)] int pageSize = 100, diff --git a/Shoko.Server/API/v3/Helpers/ModelHelper.cs b/Shoko.Server/API/v3/Helpers/ModelHelper.cs index b1e877575..b941e8a00 100644 --- a/Shoko.Server/API/v3/Helpers/ModelHelper.cs +++ b/Shoko.Server/API/v3/Helpers/ModelHelper.cs @@ -549,9 +549,11 @@ public static ListResult FilterFiles(IEnumerable input, SV if (include_only.Contains(FileIncludeOnlyType.Duplicates) && locations!.Count <= 1) return false; if (exclude.Contains(FileExcludeTypes.Unrecognized) && xrefs.Count == 0) return false; - if (include_only.Contains(FileIncludeOnlyType.Unrecognized) && xrefs.Count > 0 && xrefs.Any(x => - RepoFactory.AnimeSeries.GetByAnimeID(x.AnimeID) != null && - RepoFactory.AnimeEpisode.GetByAniDBEpisodeID(x.EpisodeID) != null)) return false; + if (include_only.Contains(FileIncludeOnlyType.Unrecognized) && xrefs.Count > 0) return false; + + // this one is also special because files in import limbo are excluded by default + if (!include_only.Contains(FileIncludeOnlyType.ImportLimbo) && !include.Contains(FileNonDefaultIncludeType.ImportLimbo) && xrefs.Count > 0 && xrefs.Any(x => x.AniDBAnime is not null && x.AniDBEpisode is not null)) return false; + if (include_only.Contains(FileIncludeOnlyType.ImportLimbo) && !(xrefs.Count > 0 && xrefs.Any(x => x.AniDBAnime is not null && x.AniDBEpisode is not null))) return false; if (exclude.Contains(FileExcludeTypes.ManualLinks) && xrefs.Count > 0 && xrefs.All(xref => xref.CrossRefSource == (int)CrossRefSource.User)) return false; diff --git a/Shoko.Server/API/v3/Models/Common/FileIncludeTypes.cs b/Shoko.Server/API/v3/Models/Common/FileIncludeTypes.cs index bf263b420..d56218e73 100644 --- a/Shoko.Server/API/v3/Models/Common/FileIncludeTypes.cs +++ b/Shoko.Server/API/v3/Models/Common/FileIncludeTypes.cs @@ -19,7 +19,8 @@ public enum FileNonDefaultIncludeType Ignored, MediaInfo, XRefs, - AbsolutePaths + AbsolutePaths, + ImportLimbo, } [JsonConverter(typeof(StringEnumConverter))] @@ -30,5 +31,6 @@ public enum FileIncludeOnlyType Duplicates, Unrecognized, ManualLinks, - Ignored + Ignored, + ImportLimbo, }