diff --git a/API.Tests/API.Tests.csproj b/API.Tests/API.Tests.csproj index 4198cf1a7..2550cbc90 100644 --- a/API.Tests/API.Tests.csproj +++ b/API.Tests/API.Tests.csproj @@ -9,14 +9,14 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/API/API.csproj b/API/API.csproj index f3f0f653e..44f362bc3 100644 --- a/API/API.csproj +++ b/API/API.csproj @@ -71,7 +71,7 @@ - + @@ -104,10 +104,10 @@ - + - + diff --git a/API/Services/Plus/LicenseService.cs b/API/Services/Plus/LicenseService.cs index 1c162c53c..e31f047b7 100644 --- a/API/Services/Plus/LicenseService.cs +++ b/API/Services/Plus/LicenseService.cs @@ -266,7 +266,7 @@ public async Task ResetLicense(string license, string email) .WithKavitaPlusHeaders(encryptedLicense.Value) .GetJsonAsync(); - // This indicates a mismatch on installid or no active subscription + // This indicates a mismatch on installId or no active subscription if (response == null) return null; // Ensure that current version is within the 3 version limit. Don't count Nightly releases or Hotfixes diff --git a/API/Services/TaskScheduler.cs b/API/Services/TaskScheduler.cs index 2dbd4ed34..8cfabb1ca 100644 --- a/API/Services/TaskScheduler.cs +++ b/API/Services/TaskScheduler.cs @@ -204,7 +204,9 @@ public async Task ScheduleKavitaPlusTasks() RecurringJob.AddOrUpdate(CheckScrobblingTokensId, () => _scrobblingService.CheckExternalAccessTokens(), Cron.Daily, RecurringJobOptions); BackgroundJob.Enqueue(() => _scrobblingService.CheckExternalAccessTokens()); // We also kick off an immediate check on startup - RecurringJob.AddOrUpdate(LicenseCheckId, () => _licenseService.HasActiveLicense(true), + + // Get the License Info (and cache it) on first load. This will internally cache the Github releases for the Version Service + RecurringJob.AddOrUpdate(LicenseCheckId, () => _licenseService.GetLicenseInfo(true), LicenseService.Cron, RecurringJobOptions); // KavitaPlus Scrobbling (every 4 hours) diff --git a/API/Services/Tasks/VersionUpdaterService.cs b/API/Services/Tasks/VersionUpdaterService.cs index 349fc6731..fd4d5b4bc 100644 --- a/API/Services/Tasks/VersionUpdaterService.cs +++ b/API/Services/Tasks/VersionUpdaterService.cs @@ -339,16 +339,15 @@ public async Task> GetAllReleases(int count = 0) return updateDtos; } - private async Task?> TryGetCachedReleases() + private static async Task?> TryGetCachedReleases() { - if (File.Exists(_cacheFilePath)) + if (!File.Exists(_cacheFilePath)) return null; + + var fileInfo = new FileInfo(_cacheFilePath); + if (DateTime.UtcNow - fileInfo.LastWriteTimeUtc <= CacheDuration) { - var fileInfo = new FileInfo(_cacheFilePath); - if (DateTime.UtcNow - fileInfo.LastWriteTimeUtc <= CacheDuration) - { - var cachedData = await File.ReadAllTextAsync(_cacheFilePath); - return System.Text.Json.JsonSerializer.Deserialize>(cachedData); - } + var cachedData = await File.ReadAllTextAsync(_cacheFilePath); + return System.Text.Json.JsonSerializer.Deserialize>(cachedData); } return null; diff --git a/UI/Web/src/app/_models/kavitaplus/license-info.ts b/UI/Web/src/app/_models/kavitaplus/license-info.ts index 139a6ae3f..4a724b3ff 100644 --- a/UI/Web/src/app/_models/kavitaplus/license-info.ts +++ b/UI/Web/src/app/_models/kavitaplus/license-info.ts @@ -2,7 +2,7 @@ export interface LicenseInfo { expirationDate: string; isActive: boolean; isCancelled: boolean; - isVersionValid: boolean; + isValidVersion: boolean; registeredEmail: string; totalMonthsSubbed: number; hasLicense: boolean; diff --git a/UI/Web/src/app/admin/license/license.component.html b/UI/Web/src/app/admin/license/license.component.html index ba8622d31..9cfb5a27a 100644 --- a/UI/Web/src/app/admin/license/license.component.html +++ b/UI/Web/src/app/admin/license/license.component.html @@ -10,7 +10,7 @@ - + @if (isChecking) { @@ -41,7 +41,7 @@ } } - @if (hasLicense && !licenseInfo) { + @if (!isChecking && hasLicense && !licenseInfo) { {{t('license-mismatch')}} } @@ -140,8 +140,8 @@ {{t('info-title')}} - - {{isVersionValid ? t('valid') : t('invalid')}] + + {{isValidVersion ? t('valid') : t('invalid')}]