fix: enable deduplication for cache mode

- Cache mode now registers downloaded songs in mappings
- Prevents duplicate downloads in cache mode
- Fixes wasted API calls and duplicate cache files
- Both cache and download modes benefit from deduplication
This commit is contained in:
2026-01-30 14:11:18 -05:00
parent 13205087ff
commit 70a56e758a

View File

@@ -298,11 +298,8 @@ public abstract class BaseDownloadService : IDownloadService
song.LocalPath = localPath; song.LocalPath = localPath;
// Register BEFORE releasing lock to prevent race conditions // Register BEFORE releasing lock to prevent race conditions (both cache and download modes)
if (!isCache)
{
await LocalLibraryService.RegisterDownloadedSongAsync(song, localPath); await LocalLibraryService.RegisterDownloadedSongAsync(song, localPath);
}
// Check if this track belongs to a playlist and update M3U // Check if this track belongs to a playlist and update M3U
if (PlaylistSyncService != null) if (PlaylistSyncService != null)
@@ -322,7 +319,7 @@ public abstract class BaseDownloadService : IDownloadService
} }
} }
// Trigger library scan and album download AFTER releasing lock // Trigger library scan and album download AFTER releasing lock (download mode only)
if (!isCache) if (!isCache)
{ {
// Trigger a Subsonic library rescan (with debounce) // Trigger a Subsonic library rescan (with debounce)