mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
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
This commit is contained in:
@@ -957,6 +957,31 @@ public class AdminController : ControllerBase
|
|||||||
await _cache.DeleteAsync(orderedCacheKey);
|
await _cache.DeleteAsync(orderedCacheKey);
|
||||||
await _cache.DeleteAsync(playlistItemsKey);
|
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);
|
_logger.LogInformation("Cleared playlist caches for {Playlist} to force rebuild", decodedName);
|
||||||
|
|
||||||
// Fetch the mapped Jellyfin track details to return to the UI
|
// Fetch the mapped Jellyfin track details to return to the UI
|
||||||
|
|||||||
Reference in New Issue
Block a user