Fix LocalLibrary infinite loading in offline mode
Problem: When app is in offline mode, LocalLibrary gets stuck in infinite loading screen and becomes unusable. Root cause: loadFolders() was calling checkFolderAccessibility() for each network folder. The backend command library_check_folder_accessible uses blocking std::fs::read_dir which can hang for 20-30 seconds per unreachable network path. Solution: Frontend (LocalLibraryView.svelte): - Skip network folder accessibility checks when offline - Assume network folders are inaccessible in offline mode - Only check accessibility when online Backend (library/commands.rs): - Add 2-second timeout to library_check_folder_accessible - Use tokio::task::spawn_blocking to avoid blocking async runtime - Log timeout warnings for unreachable network paths This allows LocalLibrary to load instantly when offline, showing only local disk content as intended. Files changed: - src/lib/components/views/LocalLibraryView.svelte - src-tauri/src/library/commands.rs
This commit is contained in:
1 parent
51cfcd1c32
commit
b450accb56
2 files changed
+27
-6
No files matched your search
@@ -329,10 +329,16 @@
|
||||
async function loadFolders() {
|
||||
try {
|
||||
folders = await invoke<LibraryFolder[]>('library_get_folders_with_metadata');
|
||||
// Check accessibility for network folders
|
||||
// Check accessibility for network folders (skip when offline to avoid hanging)
|
||||
for (const folder of folders) {
|
||||
if (folder.isNetwork) {
|
||||
checkFolderAccessibility(folder);
|
||||
if (isOffline) {
|
||||
// When offline, assume network folders are inaccessible
|
||||
folderAccessibility.set(folder.id, false);
|
||||
} else {
|
||||
// When online, check accessibility
|
||||
checkFolderAccessibility(folder);
|
||||
}
|
||||
} else {
|
||||
folderAccessibility.set(folder.id, true);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user