From 783f229a6ac4acf963a9e91dfed863b178bdefe6 Mon Sep 17 00:00:00 2001 From: Glax Date: Tue, 23 Apr 2024 00:48:08 +0200 Subject: [PATCH] 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 {