2
0

Add LibraryConnector.Test to see if requests can be made to endpoint.

This commit is contained in:
Glax 2024-04-23 00:48:08 +02:00
parent 51a26a3cba
commit 783f229a6a
3 changed files with 18 additions and 1 deletions

View File

@ -67,7 +67,15 @@ public class Kavita : LibraryConnector
foreach (KavitaLibrary lib in GetLibraries()) foreach (KavitaLibrary lib in GetLibraries())
NetClient.MakePost($"{baseUrl}/api/Library/scan?libraryId={lib.id}", "Bearer", auth, logger); 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;
}
/// <summary> /// <summary>
/// Fetches all libraries available to the user /// Fetches all libraries available to the user
/// </summary> /// </summary>

View File

@ -32,6 +32,14 @@ public class Komga : LibraryConnector
NetClient.MakePost($"{baseUrl}/api/v1/libraries/{lib.id}/scan", "Basic", auth, logger); 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;
}
/// <summary> /// <summary>
/// Fetches all libraries available to the user /// Fetches all libraries available to the user
/// </summary> /// </summary>

View File

@ -30,6 +30,7 @@ public abstract class LibraryConnector : GlobalBase
this.libraryType = libraryType; this.libraryType = libraryType;
} }
public abstract void UpdateLibrary(); public abstract void UpdateLibrary();
internal abstract bool Test();
protected static class NetClient protected static class NetClient
{ {