From 5766cf9f621551a8606423865dea44d9659c0544 Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Thu, 5 Feb 2026 09:31:07 -0500 Subject: [PATCH] Delete file caches when manual mappings are created - When mapping a track to local or external, delete both Redis and file caches - This forces the matched tracks cache to rebuild with the new mapping - Ensures manual mappings are immediately reflected in playlists --- allstarr/Controllers/AdminController.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/allstarr/Controllers/AdminController.cs b/allstarr/Controllers/AdminController.cs index 86e2dff..4e3c1a7 100644 --- a/allstarr/Controllers/AdminController.cs +++ b/allstarr/Controllers/AdminController.cs @@ -957,6 +957,31 @@ public class AdminController : ControllerBase await _cache.DeleteAsync(orderedCacheKey); await _cache.DeleteAsync(playlistItemsKey); + // Also delete file caches to force rebuild + try + { + var cacheDir = "/app/cache/spotify"; + var safeName = string.Join("_", decodedName.Split(Path.GetInvalidFileNameChars())); + var matchedFile = Path.Combine(cacheDir, $"{safeName}_matched.json"); + var itemsFile = Path.Combine(cacheDir, $"{safeName}_items.json"); + + if (System.IO.File.Exists(matchedFile)) + { + System.IO.File.Delete(matchedFile); + _logger.LogDebug("Deleted matched tracks file cache for {Playlist}", decodedName); + } + + if (System.IO.File.Exists(itemsFile)) + { + System.IO.File.Delete(itemsFile); + _logger.LogDebug("Deleted playlist items file cache for {Playlist}", decodedName); + } + } + catch (Exception ex) + { + _logger.LogWarning(ex, "Failed to delete file caches for {Playlist}", decodedName); + } + _logger.LogInformation("Cleared playlist caches for {Playlist} to force rebuild", decodedName); // Fetch the mapped Jellyfin track details to return to the UI