Fix Qobuz downloads behavior and network filtering in offline mode
Problem 1: "Show in Local Library" setting was being ignored - Qobuz downloads appeared in library even when setting was disabled - Root cause: Scanner was overwriting Qobuz downloads with INSERT OR REPLACE - This lost the 'source = qobuz_download' marker needed for filtering Problem 2: Network music visible in offline mode - Music from network folders remained visible when offline - User expected network content to be completely hidden offline - Only local disk music should appear Solution 1: Protect Qobuz downloads from scanner - Added is_qobuz_download_by_path() to check if file is already a download - Modified insert_track() to skip files with source = 'qobuz_download' - Now downloads and scanned music coexist as separate "joins" in DB Solution 2: Filter network folders when offline - Added get_network_folder_paths() to get list of network folder paths - Modified library_get_albums to accept excludeNetworkFolders parameter - When offline, filter out albums whose tracks are in network folders - Frontend passes excludeNetworkFolders: isOffline to backend - Added reactive effect to reload library when offline state changes This implements the "join between tables" approach - Qobuz downloads don't interfere with scanned music, and network content is properly hidden when offline without being deleted. Files changed: - src-tauri/src/library/database.rs - src-tauri/src/library/commands.rs - src/lib/components/views/LocalLibraryView.svelte
This commit is contained in:
1 parent
b450accb56
commit
6073cb96c1
3 files changed
+107
-7
No files matched your search
@@ -230,6 +230,17 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Reactive effect: reload library when offline state changes
|
||||
let previousOfflineState = $state<boolean | undefined>(undefined);
|
||||
$effect(() => {
|
||||
// Skip the initial mount
|
||||
if (previousOfflineState !== undefined && previousOfflineState !== isOffline) {
|
||||
console.log('Offline state changed to:', isOffline, '- reloading library data');
|
||||
loadLibraryData();
|
||||
}
|
||||
previousOfflineState = isOffline;
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
loadLibraryData();
|
||||
loadFolders();
|
||||
@@ -284,7 +295,10 @@
|
||||
|
||||
// If not found in loaded albums, we need to fetch album list first
|
||||
if (!album) {
|
||||
const allAlbums = await invoke<LocalAlbum[]>('library_get_albums', { includeHidden: false });
|
||||
const allAlbums = await invoke<LocalAlbum[]>('library_get_albums', {
|
||||
includeHidden: false,
|
||||
excludeNetworkFolders: isOffline
|
||||
});
|
||||
albums = allAlbums;
|
||||
album = allAlbums.find(a => a.id === albumId);
|
||||
}
|
||||
@@ -313,7 +327,10 @@
|
||||
error = null;
|
||||
try {
|
||||
const [albumsResult, statsResult] = await Promise.all([
|
||||
invoke<LocalAlbum[]>('library_get_albums', { includeHidden: false }),
|
||||
invoke<LocalAlbum[]>('library_get_albums', {
|
||||
includeHidden: false,
|
||||
excludeNetworkFolders: isOffline // Hide network music when offline
|
||||
}),
|
||||
invoke<LibraryStats>('library_get_stats')
|
||||
]);
|
||||
albums = albumsResult;
|
||||
@@ -896,7 +913,10 @@
|
||||
|
||||
async function loadHiddenAlbums() {
|
||||
try {
|
||||
hiddenAlbums = await invoke<LocalAlbum[]>('library_get_albums', { includeHidden: true });
|
||||
hiddenAlbums = await invoke<LocalAlbum[]>('library_get_albums', {
|
||||
includeHidden: true,
|
||||
excludeNetworkFolders: isOffline
|
||||
});
|
||||
const visibleAlbumIds = new Set(albums.map(a => a.id));
|
||||
hiddenAlbums = hiddenAlbums.filter(a => !visibleAlbumIds.has(a.id));
|
||||
} catch (err) {
|
||||
|
||||
Reference in new issue
Block a user