From 783f229a6ac4acf963a9e91dfed863b178bdefe6 Mon Sep 17 00:00:00 2001 From: Glax Date: Tue, 23 Apr 2024 00:48:08 +0200 Subject: [PATCH 1/2] Add LibraryConnector.Test to see if requests can be made to endpoint. --- Tranga/LibraryConnectors/Kavita.cs | 10 +++++++++- Tranga/LibraryConnectors/Komga.cs | 8 ++++++++ Tranga/LibraryConnectors/LibraryConnector.cs | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Tranga/LibraryConnectors/Kavita.cs b/Tranga/LibraryConnectors/Kavita.cs index 3fb8983..4dfb02b 100644 --- a/Tranga/LibraryConnectors/Kavita.cs +++ b/Tranga/LibraryConnectors/Kavita.cs @@ -67,7 +67,15 @@ public class Kavita : LibraryConnector foreach (KavitaLibrary lib in GetLibraries()) NetClient.MakePost($"{baseUrl}/api/Library/scan?libraryId={lib.id}", "Bearer", auth, logger); } - + + internal override bool Test() + { + foreach (KavitaLibrary lib in GetLibraries()) + if (NetClient.MakePost($"{baseUrl}/api/Library/scan?libraryId={lib.id}", "Bearer", auth, logger)) + return true; + return false; + } + /// /// Fetches all libraries available to the user /// diff --git a/Tranga/LibraryConnectors/Komga.cs b/Tranga/LibraryConnectors/Komga.cs index 7a0c485..557d934 100644 --- a/Tranga/LibraryConnectors/Komga.cs +++ b/Tranga/LibraryConnectors/Komga.cs @@ -32,6 +32,14 @@ public class Komga : LibraryConnector NetClient.MakePost($"{baseUrl}/api/v1/libraries/{lib.id}/scan", "Basic", auth, logger); } + internal override bool Test() + { + foreach (KomgaLibrary lib in GetLibraries()) + if (NetClient.MakePost($"{baseUrl}/api/v1/libraries/{lib.id}/scan", "Basic", auth, logger)) + return true; + return false; + } + /// /// Fetches all libraries available to the user /// diff --git a/Tranga/LibraryConnectors/LibraryConnector.cs b/Tranga/LibraryConnectors/LibraryConnector.cs index 0a66890..80dd5b2 100644 --- a/Tranga/LibraryConnectors/LibraryConnector.cs +++ b/Tranga/LibraryConnectors/LibraryConnector.cs @@ -30,6 +30,7 @@ public abstract class LibraryConnector : GlobalBase this.libraryType = libraryType; } public abstract void UpdateLibrary(); + internal abstract bool Test(); protected static class NetClient { From 58cff6513aee85e6677edc79d5a06162a7018dda Mon Sep 17 00:00:00 2001 From: Glax Date: Thu, 25 Apr 2024 20:46:26 +0200 Subject: [PATCH 2/2] Possible fix #175 --- Tranga/Jobs/UpdateMetadata.cs | 1 + Tranga/Manga.cs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Tranga/Jobs/UpdateMetadata.cs b/Tranga/Jobs/UpdateMetadata.cs index 5471685..b855f14 100644 --- a/Tranga/Jobs/UpdateMetadata.cs +++ b/Tranga/Jobs/UpdateMetadata.cs @@ -35,6 +35,7 @@ public class UpdateMetadata : Job this.manga = manga.WithMetadata(updatedManga); this.manga.SaveSeriesInfoJson(settings.downloadLocation, true); + this.mangaConnector.CopyCoverFromCacheToDownloadLocation(manga); this.progressToken.Complete(); } else diff --git a/Tranga/Manga.cs b/Tranga/Manga.cs index 388d02d..4e079c5 100644 --- a/Tranga/Manga.cs +++ b/Tranga/Manga.cs @@ -20,7 +20,7 @@ public struct Manga public string[] tags { get; private set; } // ReSharper disable once UnusedAutoPropertyAccessor.Global public string? coverUrl { get; private set; } - public string? coverFileNameInCache { get; } + public string? coverFileNameInCache { get; private set; } // ReSharper disable once UnusedAutoPropertyAccessor.Global public Dictionary links { get; } // ReSharper disable once MemberCanBePrivate.Global @@ -88,7 +88,8 @@ public struct Manga status = newManga.status, releaseStatus = newManga.releaseStatus, websiteUrl = newManga.websiteUrl, - year = newManga.year + year = newManga.year, + coverFileNameInCache = coverFileNameInCache }; } @@ -103,6 +104,7 @@ public struct Manga this.sortName == compareManga.sortName && this.latestChapterAvailable.Equals(compareManga.latestChapterAvailable) && this.authors.All(a => compareManga.authors.Contains(a)) && + (this.coverFileNameInCache??"").Equals(compareManga.coverFileNameInCache) && (this.websiteUrl??"").Equals(compareManga.websiteUrl) && this.tags.All(t => compareManga.tags.Contains(t)); }