Add network folder detection backfill and folder path editing
- Fix offline settings database migrations to run individually - Add network detection refresh when loading folder list - Add network detection during folder scan - Show folder alias with path tooltip in folder list - Add folder path change capability in FolderSettingsModal - Add network content visibility toggle in offline settings - Add i18n strings for new features (en/es)
This commit is contained in:
1 parent
c0ea039476
commit
6cabded79a
10 files changed
+343
-26
No files matched your search
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { X, HardDrive, Network, RefreshCw, Power, PowerOff, AlertTriangle } from 'lucide-svelte';
|
||||
import { open } from '@tauri-apps/plugin-dialog';
|
||||
import { X, HardDrive, Network, RefreshCw, Power, PowerOff, AlertTriangle, FolderOpen } from 'lucide-svelte';
|
||||
import { t } from '$lib/i18n';
|
||||
|
||||
// LibraryFolder type matching Rust backend
|
||||
@@ -33,6 +34,8 @@
|
||||
|
||||
// Form state
|
||||
let alias = $state('');
|
||||
let currentPath = $state('');
|
||||
let pathChanged = $state(false);
|
||||
let enabled = $state(true);
|
||||
let isNetwork = $state(false);
|
||||
let networkFsType = $state('');
|
||||
@@ -60,6 +63,8 @@
|
||||
$effect(() => {
|
||||
if (isOpen && folder) {
|
||||
alias = folder.alias || '';
|
||||
currentPath = folder.path;
|
||||
pathChanged = false;
|
||||
enabled = folder.enabled;
|
||||
isNetwork = folder.isNetwork;
|
||||
networkFsType = folder.networkFsType || '';
|
||||
@@ -92,6 +97,14 @@
|
||||
error = null;
|
||||
|
||||
try {
|
||||
// If path was changed, update it first
|
||||
if (pathChanged && currentPath !== folder.path) {
|
||||
await invoke('library_update_folder_path', {
|
||||
id: folder.id,
|
||||
newPath: currentPath
|
||||
});
|
||||
}
|
||||
|
||||
const updatedFolder = await invoke<LibraryFolder>('library_update_folder_settings', {
|
||||
id: folder.id,
|
||||
alias: alias.trim() || null,
|
||||
@@ -110,6 +123,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleChangePath() {
|
||||
try {
|
||||
const result = await open({
|
||||
directory: true,
|
||||
multiple: false,
|
||||
defaultPath: currentPath,
|
||||
title: $t('library.selectFolder')
|
||||
});
|
||||
|
||||
if (result && typeof result === 'string') {
|
||||
currentPath = result;
|
||||
pathChanged = true;
|
||||
// Re-check accessibility for the new path
|
||||
checkingAccessibility = true;
|
||||
try {
|
||||
accessible = await invoke<boolean>('library_check_folder_accessible', { path: currentPath });
|
||||
} catch (err) {
|
||||
accessible = false;
|
||||
} finally {
|
||||
checkingAccessibility = false;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to open folder picker:', err);
|
||||
error = String(err);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleScanFolder() {
|
||||
if (!folder || !onScanFolder) return;
|
||||
|
||||
@@ -150,10 +191,10 @@
|
||||
// Get display name for folder
|
||||
function getDisplayName(): string {
|
||||
if (!folder) return '';
|
||||
if (folder.alias) return folder.alias;
|
||||
if (alias) return alias;
|
||||
// Get last part of path
|
||||
const parts = folder.path.split('/').filter(Boolean);
|
||||
return parts[parts.length - 1] || folder.path;
|
||||
const parts = currentPath.split('/').filter(Boolean);
|
||||
return parts[parts.length - 1] || currentPath;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -190,8 +231,11 @@
|
||||
</div>
|
||||
<div class="folder-details">
|
||||
<span class="folder-name">{getDisplayName()}</span>
|
||||
<span class="folder-path">{folder.path}</span>
|
||||
<span class="folder-path" class:path-changed={pathChanged}>{currentPath}</span>
|
||||
</div>
|
||||
<button class="change-path-btn" onclick={handleChangePath} disabled={loading} title={$t('library.changeFolder')}>
|
||||
<FolderOpen size={16} />
|
||||
</button>
|
||||
<div class="folder-status">
|
||||
{#if checkingAccessibility}
|
||||
<span class="status checking">
|
||||
@@ -415,6 +459,35 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.folder-path.path-changed {
|
||||
color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.change-path-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: var(--bg-tertiary);
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
color: var(--text-secondary);
|
||||
cursor: pointer;
|
||||
transition: all 150ms ease;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.change-path-btn:hover:not(:disabled) {
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.change-path-btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.folder-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -1511,10 +1511,9 @@
|
||||
<HardDrive size={14} />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="folder-info">
|
||||
<div class="folder-info" title={folder.alias ? folder.path : ''}>
|
||||
{#if folder.alias}
|
||||
<span class="folder-alias">{folder.alias}</span>
|
||||
<span class="folder-path-small">{folder.path}</span>
|
||||
{:else}
|
||||
<span class="folder-path">{folder.path}</span>
|
||||
{/if}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
setAllowCastWhileOffline,
|
||||
setAllowImmediateScrobbling,
|
||||
setAllowAccumulatedScrobbling,
|
||||
setShowNetworkFoldersInManualOffline,
|
||||
checkNetwork,
|
||||
type OfflineStatus,
|
||||
type OfflineSettings
|
||||
@@ -722,6 +723,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleShowNetworkFoldersChange(enabled: boolean) {
|
||||
try {
|
||||
await setShowNetworkFoldersInManualOffline(enabled);
|
||||
} catch (error) {
|
||||
console.error('Failed to set show network folders in manual offline:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleLanguageChange(lang: string) {
|
||||
language = lang;
|
||||
const localeCode = languageToLocale[lang];
|
||||
@@ -890,13 +899,13 @@
|
||||
async function handleChangeDownloadFolder() {
|
||||
try {
|
||||
const { open } = await import('@tauri-apps/plugin-dialog');
|
||||
|
||||
|
||||
const result = await open({
|
||||
title: 'Select Downloads Folder',
|
||||
directory: true,
|
||||
defaultPath: downloadRoot || undefined
|
||||
});
|
||||
|
||||
|
||||
if (result) {
|
||||
// Validate the path
|
||||
const valid = await invoke<boolean>('validate_download_path', { path: result });
|
||||
@@ -905,6 +914,23 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this is a network folder and warn user
|
||||
interface NetworkPathInfo {
|
||||
isNetwork: boolean;
|
||||
mountInfo: { fsType: string; kind: string } | null;
|
||||
path: string;
|
||||
}
|
||||
const networkInfo = await invoke<NetworkPathInfo>('check_network_path', { path: result });
|
||||
if (networkInfo.isNetwork) {
|
||||
const proceed = confirm(
|
||||
$t('settings.networkDownloadWarning') + '\n\n' +
|
||||
$t('settings.networkDownloadWarningDetail')
|
||||
);
|
||||
if (!proceed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Ask if user wants to move existing downloads
|
||||
const hasDownloads = downloadStats && downloadStats.readyTracks > 0;
|
||||
let moveFiles = false;
|
||||
@@ -1187,7 +1213,7 @@
|
||||
</div>
|
||||
<Toggle enabled={offlineSettings.allowImmediateScrobbling} onchange={handleAllowImmediateScrobblingChange} />
|
||||
</div>
|
||||
<div class="setting-row last">
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<span class="setting-label">{$t('offline.allowAccumulatedScrobbling')}</span>
|
||||
<span class="setting-desc">{$t('offline.allowAccumulatedScrobblingDesc')}</span>
|
||||
@@ -1195,6 +1221,13 @@
|
||||
</div>
|
||||
<Toggle enabled={offlineSettings.allowAccumulatedScrobbling} onchange={handleAllowAccumulatedScrobblingChange} />
|
||||
</div>
|
||||
<div class="setting-row last">
|
||||
<div class="setting-info">
|
||||
<span class="setting-label">{$t('offline.showNetworkFolders')}</span>
|
||||
<span class="setting-desc">{$t('offline.showNetworkFoldersDesc')}</span>
|
||||
</div>
|
||||
<Toggle enabled={offlineSettings.showNetworkFoldersInManualOffline} onchange={handleShowNetworkFoldersChange} />
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
|
||||
@@ -115,6 +115,8 @@
|
||||
"networkFolderDetected": "This folder appears to be on a network drive. It may be unavailable in offline mode.",
|
||||
"disabled": "Disabled",
|
||||
"unavailable": "Unavailable",
|
||||
"changeFolder": "Change folder location",
|
||||
"selectFolder": "Select folder",
|
||||
"networkFs": {
|
||||
"auto": "Auto-detect",
|
||||
"other": "Other"
|
||||
@@ -359,6 +361,8 @@
|
||||
"clearDownloads": "Clear All",
|
||||
"openFolder": "Open Folder"
|
||||
},
|
||||
"networkDownloadWarning": "The selected folder is on a network drive.",
|
||||
"networkDownloadWarningDetail": "Downloaded tracks may not be available when the network is disconnected or in offline mode. Are you sure you want to use this location?",
|
||||
"lyrics": {
|
||||
"title": "Lyrics",
|
||||
"lyricsCache": "Lyrics Cache",
|
||||
@@ -485,7 +489,9 @@
|
||||
"allowImmediateScrobblingDesc": "Send scrobbles to Last.fm immediately while in manual offline mode",
|
||||
"allowAccumulatedScrobbling": "Accumulated Scrobbling",
|
||||
"allowAccumulatedScrobblingDesc": "Queue scrobbles for later when back online",
|
||||
"scrobbleTimeLimit": "Last.fm accepts scrobbles up to 2 weeks old"
|
||||
"scrobbleTimeLimit": "Last.fm accepts scrobbles up to 2 weeks old",
|
||||
"showNetworkFolders": "Show Network Folder Content",
|
||||
"showNetworkFoldersDesc": "Display content from network-mounted folders (NAS, Samba, etc.) while in manual offline mode"
|
||||
},
|
||||
"filter": {
|
||||
"all": "All"
|
||||
|
||||
@@ -115,6 +115,8 @@
|
||||
"networkFolderDetected": "Esta carpeta parece estar en una unidad de red. Puede no estar disponible en modo offline.",
|
||||
"disabled": "Deshabilitada",
|
||||
"unavailable": "No disponible",
|
||||
"changeFolder": "Cambiar ubicacion de carpeta",
|
||||
"selectFolder": "Seleccionar carpeta",
|
||||
"networkFs": {
|
||||
"auto": "Auto-detectar",
|
||||
"other": "Otro"
|
||||
@@ -359,6 +361,8 @@
|
||||
"clearDownloads": "Limpiar Todo",
|
||||
"openFolder": "Abrir Carpeta"
|
||||
},
|
||||
"networkDownloadWarning": "La carpeta seleccionada está en una unidad de red.",
|
||||
"networkDownloadWarningDetail": "Las pistas descargadas pueden no estar disponibles cuando la red esté desconectada o en modo offline. ¿Estás seguro de que quieres usar esta ubicación?",
|
||||
"lyrics": {
|
||||
"title": "Letras",
|
||||
"lyricsCache": "Caché de Letras",
|
||||
@@ -485,7 +489,9 @@
|
||||
"allowImmediateScrobblingDesc": "Enviar scrobbles a Last.fm inmediatamente en modo offline manual",
|
||||
"allowAccumulatedScrobbling": "Scrobbling Acumulado",
|
||||
"allowAccumulatedScrobblingDesc": "Almacenar scrobbles para enviar cuando vuelvas a estar en linea",
|
||||
"scrobbleTimeLimit": "Last.fm acepta scrobbles de hasta 2 semanas de antiguedad"
|
||||
"scrobbleTimeLimit": "Last.fm acepta scrobbles de hasta 2 semanas de antiguedad",
|
||||
"showNetworkFolders": "Mostrar Contenido de Carpetas de Red",
|
||||
"showNetworkFoldersDesc": "Mostrar contenido de carpetas montadas en red (NAS, Samba, etc.) mientras estas en modo offline manual"
|
||||
},
|
||||
"filter": {
|
||||
"all": "Todos"
|
||||
|
||||
@@ -36,6 +36,7 @@ export interface OfflineSettings {
|
||||
allowCastWhileOffline: boolean;
|
||||
allowImmediateScrobbling: boolean;
|
||||
allowAccumulatedScrobbling: boolean;
|
||||
showNetworkFoldersInManualOffline: boolean;
|
||||
}
|
||||
|
||||
// Store state
|
||||
@@ -51,6 +52,7 @@ let settings: OfflineSettings = {
|
||||
allowCastWhileOffline: false,
|
||||
allowImmediateScrobbling: false,
|
||||
allowAccumulatedScrobbling: true,
|
||||
showNetworkFoldersInManualOffline: false,
|
||||
};
|
||||
|
||||
let initialized = false;
|
||||
@@ -236,6 +238,20 @@ export async function setAllowAccumulatedScrobbling(enabled: boolean): Promise<v
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to show network folder content in manual offline mode
|
||||
*/
|
||||
export async function setShowNetworkFoldersInManualOffline(enabled: boolean): Promise<void> {
|
||||
try {
|
||||
await invoke('set_show_network_folders_in_manual_offline', { enabled });
|
||||
settings.showNetworkFoldersInManualOffline = enabled;
|
||||
notifyListeners();
|
||||
} catch (error) {
|
||||
console.error('Failed to set show network folders in manual offline:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force refresh of offline status
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user