mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-10-08 14:05:02 -04:00
fix(cache): invalidate changed runtime policies
This commit is contained in:
2 files changed
+15
-3
No files matched your search
@@ -144,7 +144,11 @@ public class ConfigControllerAuthorizationTests : IAsyncLifetime
|
||||
{
|
||||
var envPath = Path.Combine(_root, ".env");
|
||||
await File.WriteAllTextAsync(envPath, "CACHE_LYRICS_DAYS=14\n");
|
||||
var controller = CreateController(CreateHttpContextWithSession(isAdmin: true));
|
||||
var cache = new TestMemoryApplicationCache();
|
||||
await cache.SetStringAsync("lyrics:fixture", "cached");
|
||||
var controller = CreateController(
|
||||
CreateHttpContextWithSession(isAdmin: true),
|
||||
applicationCache: cache);
|
||||
|
||||
var result = Assert.IsType<OkObjectResult>(await controller.UpdateConfig(new ConfigUpdateRequest
|
||||
{
|
||||
@@ -158,6 +162,7 @@ public class ConfigControllerAuthorizationTests : IAsyncLifetime
|
||||
Assert.Equal(_tenantId, setting.TenantId);
|
||||
Assert.Equal("Cache:LyricsDays", setting.Key);
|
||||
Assert.Equal("45", setting.ValueJson);
|
||||
Assert.False(await cache.ExistsAsync("lyrics:fixture"));
|
||||
|
||||
var getResult = Assert.IsType<OkObjectResult>(await controller.GetConfig());
|
||||
using var config = JsonDocument.Parse(JsonSerializer.Serialize(
|
||||
@@ -420,7 +425,8 @@ public class ConfigControllerAuthorizationTests : IAsyncLifetime
|
||||
Dictionary<string, string?>? configValues = null,
|
||||
IHttpClientFactory? httpClientFactory = null,
|
||||
DurableProviderHealthStore? healthStore = null,
|
||||
EncryptedSecretStore? secretStore = null)
|
||||
EncryptedSecretStore? secretStore = null,
|
||||
IApplicationCache? applicationCache = null)
|
||||
{
|
||||
var logger = new Mock<ILogger<ConfigController>>();
|
||||
configValues ??= new Dictionary<string, string?>();
|
||||
@@ -434,7 +440,7 @@ public class ConfigControllerAuthorizationTests : IAsyncLifetime
|
||||
var contentRoot = Path.Combine(_root, "app");
|
||||
Directory.CreateDirectory(contentRoot);
|
||||
webHostEnvironment.SetupGet(e => e.ContentRootPath).Returns(contentRoot);
|
||||
var applicationCache = new DisabledApplicationCache();
|
||||
applicationCache ??= new DisabledApplicationCache();
|
||||
var spotifySessionCookieService = new SpotifySessionCookieService(
|
||||
Options.Create(new SpotifyApiSettings()));
|
||||
var providerStatusManager = new ProviderStatusManager(
|
||||
|
||||
@@ -350,6 +350,11 @@ public class ConfigController : ControllerBase
|
||||
"admin-ui",
|
||||
session.AllstarrUserId,
|
||||
HttpContext.RequestAborted);
|
||||
var cacheEntriesInvalidated = normalized.Any(item =>
|
||||
!item.DurableKey.StartsWith("Scrobbling:", StringComparison.OrdinalIgnoreCase) &&
|
||||
!item.DurableKey.StartsWith("WebUi:", StringComparison.OrdinalIgnoreCase))
|
||||
? await _cache.DeleteByPatternAsync("*")
|
||||
: 0;
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
@@ -357,6 +362,7 @@ public class ConfigController : ControllerBase
|
||||
updatedKeys = normalized.Select(item => item.LegacyKey).ToArray(),
|
||||
requiresRestart = false,
|
||||
changeVersion = result.ChangeVersion,
|
||||
cacheEntriesInvalidated,
|
||||
settings = result.Settings.Select(item => new { item.Key, item.Revision, item.UpdatedAt })
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user