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