Add network folder detection and folder settings
- Add network folder detection module using /proc/self/mountinfo - Detect CIFS/SMB, NFS, SSHFS, rclone, WebDAV, GlusterFS, CephFS - Classify mount types (local, network, virtual, FUSE unknown) - Check mount accessibility - Add library folder metadata - Alias for friendly naming (e.g., "NAS Music", "External Drive") - Network folder flag with auto-detection - User override for manual network folder marking - Network filesystem type (detected or user-defined) - Enabled toggle to disable folders without removing - Add FolderSettingsModal component - Edit folder alias, enabled state, network settings - Show accessibility status for network folders - Scan single folder button - Update LocalLibraryView folder list - Show network icon with connected/disconnected states - Display alias with path below if set - Edit button (enabled for single selection) - Visual badges for disabled/unavailable folders - Add Tauri commands - library_get_folders_with_metadata - library_update_folder_settings - library_scan_folder (scan single folder) - check_network_path, check_mount_accessible
This commit is contained in:
1 parent
f9ca1bd25e
commit
c0ea039476
11 files changed
+1848
-41
No files matched your search
@@ -17,6 +17,7 @@ pub mod lastfm;
|
|||||||
pub mod library;
|
pub mod library;
|
||||||
pub mod lyrics;
|
pub mod lyrics;
|
||||||
pub mod media_controls;
|
pub mod media_controls;
|
||||||
|
pub mod network;
|
||||||
pub mod offline;
|
pub mod offline;
|
||||||
pub mod player;
|
pub mod player;
|
||||||
pub mod playlist_import;
|
pub mod playlist_import;
|
||||||
@@ -360,7 +361,13 @@ pub fn run() {
|
|||||||
library::commands::library_add_folder,
|
library::commands::library_add_folder,
|
||||||
library::commands::library_remove_folder,
|
library::commands::library_remove_folder,
|
||||||
library::commands::library_get_folders,
|
library::commands::library_get_folders,
|
||||||
|
library::commands::library_get_folders_with_metadata,
|
||||||
|
library::commands::library_get_folder,
|
||||||
|
library::commands::library_update_folder_settings,
|
||||||
|
library::commands::library_set_folder_enabled,
|
||||||
|
library::commands::library_check_folder_accessible,
|
||||||
library::commands::library_scan,
|
library::commands::library_scan,
|
||||||
|
library::commands::library_scan_folder,
|
||||||
library::commands::library_get_scan_progress,
|
library::commands::library_get_scan_progress,
|
||||||
library::commands::library_stop_scan,
|
library::commands::library_stop_scan,
|
||||||
library::commands::library_get_albums,
|
library::commands::library_get_albums,
|
||||||
@@ -529,6 +536,11 @@ pub fn run() {
|
|||||||
offline::commands::mark_scrobbles_sent,
|
offline::commands::mark_scrobbles_sent,
|
||||||
offline::commands::get_queued_scrobble_count,
|
offline::commands::get_queued_scrobble_count,
|
||||||
offline::commands::cleanup_sent_scrobbles,
|
offline::commands::cleanup_sent_scrobbles,
|
||||||
|
// Network folder detection commands
|
||||||
|
network::commands::check_network_path,
|
||||||
|
network::commands::get_network_mounts_cmd,
|
||||||
|
network::commands::check_mount_accessible,
|
||||||
|
network::commands::check_network_paths_batch,
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ use tokio::sync::Mutex;
|
|||||||
use crate::api_keys::ApiKeysState;
|
use crate::api_keys::ApiKeysState;
|
||||||
use crate::discogs::DiscogsClient;
|
use crate::discogs::DiscogsClient;
|
||||||
use crate::library::{
|
use crate::library::{
|
||||||
cue_to_tracks, get_artwork_cache_dir, CueParser, LibraryDatabase, LibraryScanner, LibraryStats,
|
cue_to_tracks, get_artwork_cache_dir, CueParser, LibraryDatabase, LibraryFolder, LibraryScanner, LibraryStats,
|
||||||
LocalAlbum, LocalArtist, LocalTrack, MetadataExtractor, ScanError, ScanProgress, ScanStatus,
|
LocalAlbum, LocalArtist, LocalTrack, MetadataExtractor, ScanError, ScanProgress, ScanStatus,
|
||||||
};
|
};
|
||||||
|
use crate::network::{is_network_path, MountKind, NetworkFs};
|
||||||
|
|
||||||
/// Library state shared across commands
|
/// Library state shared across commands
|
||||||
pub struct LibraryState {
|
pub struct LibraryState {
|
||||||
@@ -31,7 +32,7 @@ fn normalize_library_path(path: &Path) -> PathBuf {
|
|||||||
pub async fn library_add_folder(
|
pub async fn library_add_folder(
|
||||||
path: String,
|
path: String,
|
||||||
state: State<'_, LibraryState>,
|
state: State<'_, LibraryState>,
|
||||||
) -> Result<(), String> {
|
) -> Result<LibraryFolder, String> {
|
||||||
log::info!("Command: library_add_folder {}", path);
|
log::info!("Command: library_add_folder {}", path);
|
||||||
|
|
||||||
// Validate path exists and is a directory
|
// Validate path exists and is a directory
|
||||||
@@ -43,8 +44,39 @@ pub async fn library_add_folder(
|
|||||||
return Err(format!("Path is not a directory: {}", path));
|
return Err(format!("Path is not a directory: {}", path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect if this is a network folder
|
||||||
|
let network_info = is_network_path(path_ref);
|
||||||
|
let (is_network, fs_type) = if network_info.is_network {
|
||||||
|
let fs_type = network_info.mount_info.as_ref().and_then(|m| {
|
||||||
|
match &m.kind {
|
||||||
|
MountKind::Network(nfs) => Some(match nfs {
|
||||||
|
NetworkFs::Cifs => "cifs".to_string(),
|
||||||
|
NetworkFs::Nfs => "nfs".to_string(),
|
||||||
|
NetworkFs::Sshfs => "sshfs".to_string(),
|
||||||
|
NetworkFs::Rclone => "rclone".to_string(),
|
||||||
|
NetworkFs::Webdav => "webdav".to_string(),
|
||||||
|
NetworkFs::Gluster => "glusterfs".to_string(),
|
||||||
|
NetworkFs::Ceph => "ceph".to_string(),
|
||||||
|
NetworkFs::Other(s) => s.clone(),
|
||||||
|
}),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
(true, fs_type)
|
||||||
|
} else {
|
||||||
|
(false, None)
|
||||||
|
};
|
||||||
|
|
||||||
|
log::info!("Folder network info: is_network={}, fs_type={:?}", is_network, fs_type);
|
||||||
|
|
||||||
let db = state.db.lock().await;
|
let db = state.db.lock().await;
|
||||||
db.add_folder(&path).map_err(|e| e.to_string())
|
let id = db.add_folder_with_network_info(&path, is_network, fs_type.as_deref())
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
// Return the full folder info
|
||||||
|
db.get_folder_by_id(id)
|
||||||
|
.map_err(|e| e.to_string())?
|
||||||
|
.ok_or_else(|| "Failed to retrieve folder after insert".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -68,6 +100,87 @@ pub async fn library_get_folders(state: State<'_, LibraryState>) -> Result<Vec<S
|
|||||||
db.get_folders().map_err(|e| e.to_string())
|
db.get_folders().map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get all library folders with full metadata
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn library_get_folders_with_metadata(
|
||||||
|
state: State<'_, LibraryState>,
|
||||||
|
) -> Result<Vec<LibraryFolder>, String> {
|
||||||
|
log::info!("Command: library_get_folders_with_metadata");
|
||||||
|
|
||||||
|
let db = state.db.lock().await;
|
||||||
|
db.get_folders_with_metadata().map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get a single folder by ID
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn library_get_folder(
|
||||||
|
id: i64,
|
||||||
|
state: State<'_, LibraryState>,
|
||||||
|
) -> Result<Option<LibraryFolder>, String> {
|
||||||
|
log::info!("Command: library_get_folder {}", id);
|
||||||
|
|
||||||
|
let db = state.db.lock().await;
|
||||||
|
db.get_folder_by_id(id).map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Update folder settings (alias, enabled, network info)
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn library_update_folder_settings(
|
||||||
|
id: i64,
|
||||||
|
alias: Option<String>,
|
||||||
|
enabled: bool,
|
||||||
|
is_network: bool,
|
||||||
|
network_fs_type: Option<String>,
|
||||||
|
user_override_network: bool,
|
||||||
|
state: State<'_, LibraryState>,
|
||||||
|
) -> Result<LibraryFolder, String> {
|
||||||
|
log::info!("Command: library_update_folder_settings {} alias={:?} enabled={}", id, alias, enabled);
|
||||||
|
|
||||||
|
let db = state.db.lock().await;
|
||||||
|
db.update_folder_settings(
|
||||||
|
id,
|
||||||
|
alias.as_deref(),
|
||||||
|
enabled,
|
||||||
|
is_network,
|
||||||
|
network_fs_type.as_deref(),
|
||||||
|
user_override_network,
|
||||||
|
).map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
db.get_folder_by_id(id)
|
||||||
|
.map_err(|e| e.to_string())?
|
||||||
|
.ok_or_else(|| "Folder not found after update".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Enable or disable a folder
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn library_set_folder_enabled(
|
||||||
|
id: i64,
|
||||||
|
enabled: bool,
|
||||||
|
state: State<'_, LibraryState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
log::info!("Command: library_set_folder_enabled {} enabled={}", id, enabled);
|
||||||
|
|
||||||
|
let db = state.db.lock().await;
|
||||||
|
db.set_folder_enabled(id, enabled).map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check network accessibility for a folder
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn library_check_folder_accessible(path: String) -> Result<bool, String> {
|
||||||
|
log::info!("Command: library_check_folder_accessible {}", path);
|
||||||
|
|
||||||
|
let path_ref = Path::new(&path);
|
||||||
|
if !path_ref.exists() {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to read the directory
|
||||||
|
match std::fs::read_dir(path_ref) {
|
||||||
|
Ok(_) => Ok(true),
|
||||||
|
Err(_) => Ok(false),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// === Scanning ===
|
// === Scanning ===
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -328,6 +441,198 @@ pub async fn library_stop_scan(state: State<'_, LibraryState>) -> Result<(), Str
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Scan a single folder (by ID)
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn library_scan_folder(
|
||||||
|
folder_id: i64,
|
||||||
|
state: State<'_, LibraryState>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
log::info!("Command: library_scan_folder {}", folder_id);
|
||||||
|
|
||||||
|
// Get folder info
|
||||||
|
let folder = {
|
||||||
|
let db = state.db.lock().await;
|
||||||
|
db.get_folder_by_id(folder_id)
|
||||||
|
.map_err(|e| e.to_string())?
|
||||||
|
.ok_or_else(|| format!("Folder with ID {} not found", folder_id))?
|
||||||
|
};
|
||||||
|
|
||||||
|
if !folder.enabled {
|
||||||
|
return Err("Cannot scan disabled folder".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset cancel flag and progress
|
||||||
|
state.scan_cancel.store(false, Ordering::Relaxed);
|
||||||
|
{
|
||||||
|
let mut progress = state.scan_progress.lock().await;
|
||||||
|
*progress = ScanProgress {
|
||||||
|
status: ScanStatus::Scanning,
|
||||||
|
total_files: 0,
|
||||||
|
processed_files: 0,
|
||||||
|
current_file: None,
|
||||||
|
errors: Vec::new(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let scanner = LibraryScanner::new();
|
||||||
|
let mut all_errors: Vec<ScanError> = Vec::new();
|
||||||
|
|
||||||
|
log::info!("Scanning single folder: {}", folder.path);
|
||||||
|
|
||||||
|
// Scan for files
|
||||||
|
let scan_result = match scanner.scan_directory(Path::new(&folder.path)) {
|
||||||
|
Ok(result) => result,
|
||||||
|
Err(e) => {
|
||||||
|
let mut progress = state.scan_progress.lock().await;
|
||||||
|
progress.status = ScanStatus::Complete;
|
||||||
|
progress.errors = vec![ScanError {
|
||||||
|
file_path: folder.path.clone(),
|
||||||
|
error: e.to_string(),
|
||||||
|
}];
|
||||||
|
return Err(e.to_string());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let total_files = scan_result.audio_files.len() + scan_result.cue_files.len();
|
||||||
|
|
||||||
|
// Update total count
|
||||||
|
{
|
||||||
|
let mut progress = state.scan_progress.lock().await;
|
||||||
|
progress.total_files = total_files as u32;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process CUE files first
|
||||||
|
for cue_path in &scan_result.cue_files {
|
||||||
|
if state.scan_cancel.load(Ordering::Relaxed) {
|
||||||
|
let mut progress = state.scan_progress.lock().await;
|
||||||
|
progress.status = ScanStatus::Cancelled;
|
||||||
|
progress.current_file = None;
|
||||||
|
log::info!("Library scan cancelled by user");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut progress = state.scan_progress.lock().await;
|
||||||
|
progress.current_file = Some(cue_path.to_string_lossy().to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
match process_cue_file(cue_path, &state).await {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(e) => {
|
||||||
|
all_errors.push(ScanError {
|
||||||
|
file_path: cue_path.to_string_lossy().to_string(),
|
||||||
|
error: e,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut progress = state.scan_progress.lock().await;
|
||||||
|
progress.processed_files += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process regular audio files
|
||||||
|
let cue_audio_files: std::collections::HashSet<String> = scan_result
|
||||||
|
.cue_files
|
||||||
|
.iter()
|
||||||
|
.filter_map(|p| {
|
||||||
|
CueParser::parse(p).ok().map(|cue| {
|
||||||
|
normalize_library_path(Path::new(&cue.audio_file))
|
||||||
|
.to_string_lossy()
|
||||||
|
.to_string()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
for audio_path in &scan_result.audio_files {
|
||||||
|
if state.scan_cancel.load(Ordering::Relaxed) {
|
||||||
|
let mut progress = state.scan_progress.lock().await;
|
||||||
|
progress.status = ScanStatus::Cancelled;
|
||||||
|
progress.current_file = None;
|
||||||
|
log::info!("Library scan cancelled by user");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let canonical_path = normalize_library_path(audio_path);
|
||||||
|
let path_str = canonical_path.to_string_lossy().to_string();
|
||||||
|
if cue_audio_files.contains(&path_str) {
|
||||||
|
let mut progress = state.scan_progress.lock().await;
|
||||||
|
progress.processed_files += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut progress = state.scan_progress.lock().await;
|
||||||
|
progress.current_file = Some(path_str.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
match MetadataExtractor::extract(&canonical_path) {
|
||||||
|
Ok(mut track) => {
|
||||||
|
let artwork_cache = get_artwork_cache_dir();
|
||||||
|
let mut artwork_path = MetadataExtractor::extract_artwork(&canonical_path, &artwork_cache);
|
||||||
|
if artwork_path.is_none() {
|
||||||
|
if let Some(folder_art) = MetadataExtractor::find_folder_artwork(
|
||||||
|
canonical_path.as_path(),
|
||||||
|
Some(&track.album),
|
||||||
|
) {
|
||||||
|
artwork_path = MetadataExtractor::cache_artwork_file(
|
||||||
|
Path::new(&folder_art),
|
||||||
|
&artwork_cache,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
track.artwork_path = artwork_path.clone();
|
||||||
|
|
||||||
|
let db = state.db.lock().await;
|
||||||
|
let group_key = track.album_group_key.clone();
|
||||||
|
if let Err(e) = db.insert_track(&track) {
|
||||||
|
all_errors.push(ScanError {
|
||||||
|
file_path: path_str,
|
||||||
|
error: e.to_string(),
|
||||||
|
});
|
||||||
|
} else if let Some(path) = artwork_path.as_ref() {
|
||||||
|
if !group_key.is_empty() {
|
||||||
|
let _ = db.update_album_group_artwork(&group_key, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
all_errors.push(ScanError {
|
||||||
|
file_path: path_str,
|
||||||
|
error: e.to_string(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut progress = state.scan_progress.lock().await;
|
||||||
|
progress.processed_files += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update folder scan time
|
||||||
|
{
|
||||||
|
let now = std::time::SystemTime::now()
|
||||||
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
|
.map(|d| d.as_secs() as i64)
|
||||||
|
.unwrap_or(0);
|
||||||
|
let db = state.db.lock().await;
|
||||||
|
let _ = db.update_folder_scan_time(&folder.path, now);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update final status
|
||||||
|
{
|
||||||
|
let mut progress = state.scan_progress.lock().await;
|
||||||
|
progress.status = ScanStatus::Complete;
|
||||||
|
progress.current_file = None;
|
||||||
|
progress.errors = all_errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
log::info!("Single folder scan complete");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
// === Queries ===
|
// === Queries ===
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
@@ -289,12 +289,32 @@ impl LibraryDatabase {
|
|||||||
.map_err(|e| LibraryError::Database(format!("Migration failed: {}", e)))?;
|
.map_err(|e| LibraryError::Database(format!("Migration failed: {}", e)))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Migration: Add folder metadata columns (alias, network info)
|
||||||
|
let has_folder_alias: bool = self.conn
|
||||||
|
.query_row(
|
||||||
|
"SELECT COUNT(*) FROM pragma_table_info('library_folders') WHERE name = 'alias'",
|
||||||
|
[],
|
||||||
|
|row| row.get::<_, i32>(0),
|
||||||
|
)
|
||||||
|
.map(|count| count > 0)
|
||||||
|
.unwrap_or(false);
|
||||||
|
|
||||||
|
if !has_folder_alias {
|
||||||
|
log::info!("Running migration: adding folder metadata columns (alias, network info)");
|
||||||
|
self.conn.execute_batch(
|
||||||
|
"ALTER TABLE library_folders ADD COLUMN alias TEXT;
|
||||||
|
ALTER TABLE library_folders ADD COLUMN is_network INTEGER DEFAULT 0;
|
||||||
|
ALTER TABLE library_folders ADD COLUMN network_fs_type TEXT;
|
||||||
|
ALTER TABLE library_folders ADD COLUMN user_override_network INTEGER DEFAULT 0;"
|
||||||
|
).map_err(|e| LibraryError::Database(format!("Migration failed: {}", e)))?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Folder Management ===
|
// === Folder Management ===
|
||||||
|
|
||||||
/// Add a folder to the library
|
/// Add a folder to the library with optional network info
|
||||||
pub fn add_folder(&self, path: &str) -> Result<(), LibraryError> {
|
pub fn add_folder(&self, path: &str) -> Result<(), LibraryError> {
|
||||||
self.conn
|
self.conn
|
||||||
.execute(
|
.execute(
|
||||||
@@ -305,6 +325,32 @@ impl LibraryDatabase {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add a folder with network detection info
|
||||||
|
pub fn add_folder_with_network_info(
|
||||||
|
&self,
|
||||||
|
path: &str,
|
||||||
|
is_network: bool,
|
||||||
|
network_fs_type: Option<&str>,
|
||||||
|
) -> Result<i64, LibraryError> {
|
||||||
|
self.conn
|
||||||
|
.execute(
|
||||||
|
"INSERT OR IGNORE INTO library_folders (path, is_network, network_fs_type) VALUES (?, ?, ?)",
|
||||||
|
params![path, is_network as i32, network_fs_type],
|
||||||
|
)
|
||||||
|
.map_err(|e| LibraryError::Database(e.to_string()))?;
|
||||||
|
|
||||||
|
// Get the folder ID (either newly inserted or existing)
|
||||||
|
let id: i64 = self.conn
|
||||||
|
.query_row(
|
||||||
|
"SELECT id FROM library_folders WHERE path = ?",
|
||||||
|
params![path],
|
||||||
|
|row| row.get(0),
|
||||||
|
)
|
||||||
|
.map_err(|e| LibraryError::Database(e.to_string()))?;
|
||||||
|
|
||||||
|
Ok(id)
|
||||||
|
}
|
||||||
|
|
||||||
/// Remove a folder from the library
|
/// Remove a folder from the library
|
||||||
pub fn remove_folder(&self, path: &str) -> Result<(), LibraryError> {
|
pub fn remove_folder(&self, path: &str) -> Result<(), LibraryError> {
|
||||||
self.conn
|
self.conn
|
||||||
@@ -313,7 +359,7 @@ impl LibraryDatabase {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get all enabled library folders
|
/// Get all enabled library folders (paths only, for scanning)
|
||||||
pub fn get_folders(&self) -> Result<Vec<String>, LibraryError> {
|
pub fn get_folders(&self) -> Result<Vec<String>, LibraryError> {
|
||||||
let mut stmt = self
|
let mut stmt = self
|
||||||
.conn
|
.conn
|
||||||
@@ -331,6 +377,97 @@ impl LibraryDatabase {
|
|||||||
Ok(folders)
|
Ok(folders)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get all library folders with full metadata
|
||||||
|
pub fn get_folders_with_metadata(&self) -> Result<Vec<LibraryFolder>, LibraryError> {
|
||||||
|
let mut stmt = self
|
||||||
|
.conn
|
||||||
|
.prepare(
|
||||||
|
"SELECT id, path, alias, enabled, is_network, network_fs_type, user_override_network, last_scan
|
||||||
|
FROM library_folders ORDER BY path"
|
||||||
|
)
|
||||||
|
.map_err(|e| LibraryError::Database(e.to_string()))?;
|
||||||
|
|
||||||
|
let rows = stmt
|
||||||
|
.query_map([], |row| {
|
||||||
|
Ok(LibraryFolder {
|
||||||
|
id: row.get(0)?,
|
||||||
|
path: row.get(1)?,
|
||||||
|
alias: row.get(2)?,
|
||||||
|
enabled: row.get::<_, i32>(3)? != 0,
|
||||||
|
is_network: row.get::<_, i32>(4).unwrap_or(0) != 0,
|
||||||
|
network_fs_type: row.get(5)?,
|
||||||
|
user_override_network: row.get::<_, i32>(6).unwrap_or(0) != 0,
|
||||||
|
last_scan: row.get(7)?,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.map_err(|e| LibraryError::Database(e.to_string()))?;
|
||||||
|
|
||||||
|
let mut folders = Vec::new();
|
||||||
|
for folder in rows {
|
||||||
|
folders.push(folder.map_err(|e| LibraryError::Database(e.to_string()))?);
|
||||||
|
}
|
||||||
|
Ok(folders)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get a single folder by ID
|
||||||
|
pub fn get_folder_by_id(&self, id: i64) -> Result<Option<LibraryFolder>, LibraryError> {
|
||||||
|
let result = self
|
||||||
|
.conn
|
||||||
|
.query_row(
|
||||||
|
"SELECT id, path, alias, enabled, is_network, network_fs_type, user_override_network, last_scan
|
||||||
|
FROM library_folders WHERE id = ?",
|
||||||
|
params![id],
|
||||||
|
|row| {
|
||||||
|
Ok(LibraryFolder {
|
||||||
|
id: row.get(0)?,
|
||||||
|
path: row.get(1)?,
|
||||||
|
alias: row.get(2)?,
|
||||||
|
enabled: row.get::<_, i32>(3)? != 0,
|
||||||
|
is_network: row.get::<_, i32>(4).unwrap_or(0) != 0,
|
||||||
|
network_fs_type: row.get(5)?,
|
||||||
|
user_override_network: row.get::<_, i32>(6).unwrap_or(0) != 0,
|
||||||
|
last_scan: row.get(7)?,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.optional()
|
||||||
|
.map_err(|e| LibraryError::Database(e.to_string()))?;
|
||||||
|
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Update folder settings
|
||||||
|
pub fn update_folder_settings(
|
||||||
|
&self,
|
||||||
|
id: i64,
|
||||||
|
alias: Option<&str>,
|
||||||
|
enabled: bool,
|
||||||
|
is_network: bool,
|
||||||
|
network_fs_type: Option<&str>,
|
||||||
|
user_override_network: bool,
|
||||||
|
) -> Result<(), LibraryError> {
|
||||||
|
self.conn
|
||||||
|
.execute(
|
||||||
|
"UPDATE library_folders
|
||||||
|
SET alias = ?, enabled = ?, is_network = ?, network_fs_type = ?, user_override_network = ?
|
||||||
|
WHERE id = ?",
|
||||||
|
params![alias, enabled as i32, is_network as i32, network_fs_type, user_override_network as i32, id],
|
||||||
|
)
|
||||||
|
.map_err(|e| LibraryError::Database(e.to_string()))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set folder enabled state
|
||||||
|
pub fn set_folder_enabled(&self, id: i64, enabled: bool) -> Result<(), LibraryError> {
|
||||||
|
self.conn
|
||||||
|
.execute(
|
||||||
|
"UPDATE library_folders SET enabled = ? WHERE id = ?",
|
||||||
|
params![enabled as i32, id],
|
||||||
|
)
|
||||||
|
.map_err(|e| LibraryError::Database(e.to_string()))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Update last scan time for a folder
|
/// Update last scan time for a folder
|
||||||
pub fn update_folder_scan_time(&self, path: &str, timestamp: i64) -> Result<(), LibraryError> {
|
pub fn update_folder_scan_time(&self, path: &str, timestamp: i64) -> Result<(), LibraryError> {
|
||||||
self.conn
|
self.conn
|
||||||
@@ -846,6 +983,20 @@ pub struct LibraryStats {
|
|||||||
pub total_size_bytes: u64,
|
pub total_size_bytes: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Library folder with metadata
|
||||||
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct LibraryFolder {
|
||||||
|
pub id: i64,
|
||||||
|
pub path: String,
|
||||||
|
pub alias: Option<String>,
|
||||||
|
pub enabled: bool,
|
||||||
|
pub is_network: bool,
|
||||||
|
pub network_fs_type: Option<String>,
|
||||||
|
pub user_override_network: bool,
|
||||||
|
pub last_scan: Option<i64>,
|
||||||
|
}
|
||||||
|
|
||||||
/// Playlist local settings (enhances remote Qobuz playlists)
|
/// Playlist local settings (enhances remote Qobuz playlists)
|
||||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct PlaylistSettings {
|
pub struct PlaylistSettings {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub mod scanner;
|
|||||||
|
|
||||||
pub use commands::LibraryState;
|
pub use commands::LibraryState;
|
||||||
pub use cue_parser::{cue_to_tracks, CueParser, CueSheet, CueTrack};
|
pub use cue_parser::{cue_to_tracks, CueParser, CueSheet, CueTrack};
|
||||||
pub use database::{LibraryDatabase, LibraryStats, PlaylistSettings, PlaylistStats};
|
pub use database::{LibraryDatabase, LibraryFolder, LibraryStats, PlaylistSettings, PlaylistStats};
|
||||||
pub use errors::LibraryError;
|
pub use errors::LibraryError;
|
||||||
pub use metadata::MetadataExtractor;
|
pub use metadata::MetadataExtractor;
|
||||||
pub use models::*;
|
pub use models::*;
|
||||||
|
|||||||
@@ -0,0 +1,441 @@
|
|||||||
|
//! Network folder detection module
|
||||||
|
//!
|
||||||
|
//! Detects if a path is on a network-mounted filesystem (NAS, DAS, Samba, NFS, etc.)
|
||||||
|
//! by parsing /proc/self/mountinfo on Linux.
|
||||||
|
//!
|
||||||
|
//! Used by:
|
||||||
|
//! - Download folder selection (warning for network folders)
|
||||||
|
//! - Library folder management (network folder indicator)
|
||||||
|
//! - Offline mode (accessibility of network content)
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
/// Type of mount point
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum MountKind {
|
||||||
|
/// Local storage (ext4, btrfs, xfs, ntfs, vfat, etc.)
|
||||||
|
Local,
|
||||||
|
/// Network filesystem (SMB, NFS, SSHFS, etc.)
|
||||||
|
Network(NetworkFs),
|
||||||
|
/// Virtual/pseudo filesystem (/proc, /sys, tmpfs, etc.)
|
||||||
|
Virtual,
|
||||||
|
/// FUSE filesystem of unknown type
|
||||||
|
FuseUnknown,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Specific network filesystem types
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum NetworkFs {
|
||||||
|
/// SMB/CIFS (Samba, Windows shares)
|
||||||
|
Cifs,
|
||||||
|
/// NFS (Network File System)
|
||||||
|
Nfs,
|
||||||
|
/// SSHFS (SSH Filesystem)
|
||||||
|
Sshfs,
|
||||||
|
/// rclone mount (cloud storage)
|
||||||
|
Rclone,
|
||||||
|
/// WebDAV
|
||||||
|
Webdav,
|
||||||
|
/// GlusterFS
|
||||||
|
Gluster,
|
||||||
|
/// CephFS
|
||||||
|
Ceph,
|
||||||
|
/// Other network filesystem
|
||||||
|
Other(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Information about a mount point
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct MountInfo {
|
||||||
|
/// Filesystem type (e.g., "ext4", "cifs", "nfs")
|
||||||
|
pub fs_type: String,
|
||||||
|
/// Mount point path
|
||||||
|
pub mount_point: String,
|
||||||
|
/// Mount source (device or remote path)
|
||||||
|
pub source: String,
|
||||||
|
/// Classified mount kind
|
||||||
|
pub kind: MountKind,
|
||||||
|
/// Whether the mount is currently accessible
|
||||||
|
pub accessible: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Result of checking if a path is on a network mount
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct NetworkPathInfo {
|
||||||
|
/// Whether the path is on a network filesystem
|
||||||
|
pub is_network: bool,
|
||||||
|
/// Mount information if found
|
||||||
|
pub mount_info: Option<MountInfo>,
|
||||||
|
/// The path that was checked
|
||||||
|
pub path: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Cached mount information for performance
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct MountCache {
|
||||||
|
mounts: Vec<MountInfo>,
|
||||||
|
last_refresh: std::time::Instant,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MountCache {
|
||||||
|
/// Create a new mount cache
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
mounts: Vec::new(),
|
||||||
|
last_refresh: std::time::Instant::now() - std::time::Duration::from_secs(3600),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Refresh mount information from /proc/self/mountinfo
|
||||||
|
pub fn refresh(&mut self) {
|
||||||
|
self.mounts = parse_mount_info().unwrap_or_default();
|
||||||
|
self.last_refresh = std::time::Instant::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get mounts, refreshing if stale (older than 30 seconds)
|
||||||
|
pub fn get_mounts(&mut self) -> &[MountInfo] {
|
||||||
|
if self.last_refresh.elapsed() > std::time::Duration::from_secs(30) {
|
||||||
|
self.refresh();
|
||||||
|
}
|
||||||
|
&self.mounts
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Force refresh and return mounts
|
||||||
|
pub fn get_mounts_fresh(&mut self) -> &[MountInfo] {
|
||||||
|
self.refresh();
|
||||||
|
&self.mounts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Classify a filesystem type into MountKind
|
||||||
|
fn classify_fs_type(fs_type: &str, source: &str) -> MountKind {
|
||||||
|
let fs_lower = fs_type.to_lowercase();
|
||||||
|
|
||||||
|
// Network filesystems
|
||||||
|
match fs_lower.as_str() {
|
||||||
|
"cifs" | "smb" | "smb3" | "smbfs" => {
|
||||||
|
return MountKind::Network(NetworkFs::Cifs);
|
||||||
|
}
|
||||||
|
"nfs" | "nfs4" | "nfsd" => {
|
||||||
|
return MountKind::Network(NetworkFs::Nfs);
|
||||||
|
}
|
||||||
|
"sshfs" => {
|
||||||
|
return MountKind::Network(NetworkFs::Sshfs);
|
||||||
|
}
|
||||||
|
"rclone" => {
|
||||||
|
return MountKind::Network(NetworkFs::Rclone);
|
||||||
|
}
|
||||||
|
"davfs" | "davfs2" | "webdav" => {
|
||||||
|
return MountKind::Network(NetworkFs::Webdav);
|
||||||
|
}
|
||||||
|
"glusterfs" => {
|
||||||
|
return MountKind::Network(NetworkFs::Gluster);
|
||||||
|
}
|
||||||
|
"ceph" => {
|
||||||
|
return MountKind::Network(NetworkFs::Ceph);
|
||||||
|
}
|
||||||
|
// FUSE types that might be network
|
||||||
|
"fuse.sshfs" => {
|
||||||
|
return MountKind::Network(NetworkFs::Sshfs);
|
||||||
|
}
|
||||||
|
"fuse.rclone" => {
|
||||||
|
return MountKind::Network(NetworkFs::Rclone);
|
||||||
|
}
|
||||||
|
"fuse.cifs" => {
|
||||||
|
return MountKind::Network(NetworkFs::Cifs);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for FUSE with network-like source patterns
|
||||||
|
if fs_lower.starts_with("fuse") {
|
||||||
|
// Check source for network patterns
|
||||||
|
if source.contains("@") || source.contains("://") {
|
||||||
|
// Likely SSHFS (user@host:path) or URL-based mount
|
||||||
|
if source.contains("@") && source.contains(":") {
|
||||||
|
return MountKind::Network(NetworkFs::Sshfs);
|
||||||
|
}
|
||||||
|
return MountKind::Network(NetworkFs::Other(fs_type.to_string()));
|
||||||
|
}
|
||||||
|
return MountKind::FuseUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Virtual/pseudo filesystems
|
||||||
|
match fs_lower.as_str() {
|
||||||
|
"proc" | "sysfs" | "devtmpfs" | "devpts" | "tmpfs" | "ramfs"
|
||||||
|
| "securityfs" | "debugfs" | "tracefs" | "configfs" | "cgroup"
|
||||||
|
| "cgroup2" | "pstore" | "efivarfs" | "bpf" | "autofs"
|
||||||
|
| "mqueue" | "hugetlbfs" | "fusectl" | "overlay" | "squashfs" => {
|
||||||
|
return MountKind::Virtual;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Local filesystems
|
||||||
|
match fs_lower.as_str() {
|
||||||
|
"ext2" | "ext3" | "ext4" | "xfs" | "btrfs" | "zfs"
|
||||||
|
| "ntfs" | "ntfs3" | "vfat" | "fat32" | "exfat" | "hfs"
|
||||||
|
| "hfsplus" | "apfs" | "f2fs" | "jfs" | "reiserfs" | "udf"
|
||||||
|
| "iso9660" | "ufs" => {
|
||||||
|
return MountKind::Local;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default to local for unknown types (conservative approach)
|
||||||
|
MountKind::Local
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parse /proc/self/mountinfo and return mount information
|
||||||
|
fn parse_mount_info() -> Result<Vec<MountInfo>, String> {
|
||||||
|
let content = fs::read_to_string("/proc/self/mountinfo")
|
||||||
|
.map_err(|e| format!("Failed to read /proc/self/mountinfo: {}", e))?;
|
||||||
|
|
||||||
|
let mut mounts = Vec::new();
|
||||||
|
|
||||||
|
for line in content.lines() {
|
||||||
|
if let Some(mount) = parse_mount_line(line) {
|
||||||
|
mounts.push(mount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(mounts)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parse a single line from /proc/self/mountinfo
|
||||||
|
/// Format: mount_id parent_id major:minor root mount_point mount_options ... - fs_type mount_source super_options
|
||||||
|
fn parse_mount_line(line: &str) -> Option<MountInfo> {
|
||||||
|
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||||
|
|
||||||
|
// Need at least the basic fields plus separator
|
||||||
|
if parts.len() < 7 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the separator "-" to split fixed and optional parts
|
||||||
|
let separator_idx = parts.iter().position(|&s| s == "-")?;
|
||||||
|
|
||||||
|
// mount_point is at index 4
|
||||||
|
let mount_point = parts.get(4)?.to_string();
|
||||||
|
|
||||||
|
// After separator: fs_type, mount_source, super_options
|
||||||
|
let fs_type = parts.get(separator_idx + 1)?.to_string();
|
||||||
|
let source = parts.get(separator_idx + 2).unwrap_or(&"").to_string();
|
||||||
|
|
||||||
|
// Unescape mount point (replaces \040 with space, etc.)
|
||||||
|
let mount_point = unescape_mount_path(&mount_point);
|
||||||
|
|
||||||
|
let kind = classify_fs_type(&fs_type, &source);
|
||||||
|
|
||||||
|
// Check accessibility with a quick stat
|
||||||
|
let accessible = Path::new(&mount_point).exists()
|
||||||
|
&& std::fs::metadata(&mount_point).is_ok();
|
||||||
|
|
||||||
|
Some(MountInfo {
|
||||||
|
fs_type,
|
||||||
|
mount_point,
|
||||||
|
source,
|
||||||
|
kind,
|
||||||
|
accessible,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Unescape mount path (handles \040 for space, etc.)
|
||||||
|
fn unescape_mount_path(path: &str) -> String {
|
||||||
|
let mut result = String::with_capacity(path.len());
|
||||||
|
let mut chars = path.chars().peekable();
|
||||||
|
|
||||||
|
while let Some(c) = chars.next() {
|
||||||
|
if c == '\\' {
|
||||||
|
// Read up to 3 octal digits
|
||||||
|
let mut octal = String::new();
|
||||||
|
for _ in 0..3 {
|
||||||
|
if let Some(&next) = chars.peek() {
|
||||||
|
if next.is_ascii_digit() && next < '8' {
|
||||||
|
octal.push(chars.next().unwrap());
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !octal.is_empty() {
|
||||||
|
if let Ok(code) = u8::from_str_radix(&octal, 8) {
|
||||||
|
result.push(code as char);
|
||||||
|
} else {
|
||||||
|
result.push('\\');
|
||||||
|
result.push_str(&octal);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.push('\\');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.push(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Find the mount point for a given path
|
||||||
|
pub fn find_mount_for_path(path: &Path, mounts: &[MountInfo]) -> Option<MountInfo> {
|
||||||
|
// Canonicalize path to resolve symlinks
|
||||||
|
let canonical = match path.canonicalize() {
|
||||||
|
Ok(p) => p,
|
||||||
|
Err(_) => path.to_path_buf(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let path_str = canonical.to_string_lossy();
|
||||||
|
|
||||||
|
// Find the longest matching mount point (most specific)
|
||||||
|
let mut best_match: Option<&MountInfo> = None;
|
||||||
|
let mut best_len = 0;
|
||||||
|
|
||||||
|
for mount in mounts {
|
||||||
|
if path_str.starts_with(&mount.mount_point) || path_str == mount.mount_point {
|
||||||
|
let mount_len = mount.mount_point.len();
|
||||||
|
// Make sure it's a proper path prefix (ends at directory boundary)
|
||||||
|
let is_valid_prefix = path_str.len() == mount_len
|
||||||
|
|| path_str.chars().nth(mount_len) == Some('/')
|
||||||
|
|| mount.mount_point == "/";
|
||||||
|
|
||||||
|
if is_valid_prefix && mount_len > best_len {
|
||||||
|
best_match = Some(mount);
|
||||||
|
best_len = mount_len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
best_match.cloned()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if a path is on a network filesystem
|
||||||
|
pub fn is_network_path(path: &Path) -> NetworkPathInfo {
|
||||||
|
let mounts = parse_mount_info().unwrap_or_default();
|
||||||
|
|
||||||
|
if let Some(mount) = find_mount_for_path(path, &mounts) {
|
||||||
|
let is_network = matches!(mount.kind, MountKind::Network(_));
|
||||||
|
NetworkPathInfo {
|
||||||
|
is_network,
|
||||||
|
mount_info: Some(mount),
|
||||||
|
path: path.to_string_lossy().to_string(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
NetworkPathInfo {
|
||||||
|
is_network: false,
|
||||||
|
mount_info: None,
|
||||||
|
path: path.to_string_lossy().to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check accessibility of a network mount with timeout
|
||||||
|
pub fn check_mount_accessibility(mount_point: &str) -> bool {
|
||||||
|
// Use a quick readdir operation
|
||||||
|
let path = Path::new(mount_point);
|
||||||
|
|
||||||
|
// First check if path exists
|
||||||
|
if !path.exists() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to read directory to verify access
|
||||||
|
match fs::read_dir(path) {
|
||||||
|
Ok(mut entries) => {
|
||||||
|
// Try to read at least one entry
|
||||||
|
entries.next().is_some() || true // Empty dir is still accessible
|
||||||
|
}
|
||||||
|
Err(_) => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get all network mounts
|
||||||
|
pub fn get_network_mounts() -> Vec<MountInfo> {
|
||||||
|
parse_mount_info()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.into_iter()
|
||||||
|
.filter(|m| matches!(m.kind, MountKind::Network(_)))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get all mounts with their classifications
|
||||||
|
pub fn get_all_mounts() -> Vec<MountInfo> {
|
||||||
|
parse_mount_info().unwrap_or_default()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tauri commands
|
||||||
|
pub mod commands {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
/// Check if a path is on a network filesystem
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn check_network_path(path: String) -> NetworkPathInfo {
|
||||||
|
is_network_path(Path::new(&path))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get all network mounts currently visible
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_network_mounts_cmd() -> Vec<MountInfo> {
|
||||||
|
get_network_mounts()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if a network mount is currently accessible
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn check_mount_accessible(mount_point: String) -> bool {
|
||||||
|
check_mount_accessibility(&mount_point)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Batch check multiple paths for network status
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn check_network_paths_batch(paths: Vec<String>) -> HashMap<String, NetworkPathInfo> {
|
||||||
|
let mounts = parse_mount_info().unwrap_or_default();
|
||||||
|
|
||||||
|
paths
|
||||||
|
.into_iter()
|
||||||
|
.map(|p| {
|
||||||
|
let path = Path::new(&p);
|
||||||
|
let info = if let Some(mount) = find_mount_for_path(path, &mounts) {
|
||||||
|
let is_network = matches!(mount.kind, MountKind::Network(_));
|
||||||
|
NetworkPathInfo {
|
||||||
|
is_network,
|
||||||
|
mount_info: Some(mount),
|
||||||
|
path: p.clone(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
NetworkPathInfo {
|
||||||
|
is_network: false,
|
||||||
|
mount_info: None,
|
||||||
|
path: p.clone(),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
(p, info)
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_classify_fs_type() {
|
||||||
|
assert!(matches!(classify_fs_type("ext4", ""), MountKind::Local));
|
||||||
|
assert!(matches!(classify_fs_type("cifs", "//server/share"), MountKind::Network(NetworkFs::Cifs)));
|
||||||
|
assert!(matches!(classify_fs_type("nfs", "server:/export"), MountKind::Network(NetworkFs::Nfs)));
|
||||||
|
assert!(matches!(classify_fs_type("tmpfs", "tmpfs"), MountKind::Virtual));
|
||||||
|
assert!(matches!(classify_fs_type("fuse.sshfs", "user@host:/path"), MountKind::Network(NetworkFs::Sshfs)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_unescape_mount_path() {
|
||||||
|
assert_eq!(unescape_mount_path("/mnt/My\\040Drive"), "/mnt/My Drive");
|
||||||
|
assert_eq!(unescape_mount_path("/normal/path"), "/normal/path");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,628 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { invoke } from '@tauri-apps/api/core';
|
||||||
|
import { X, HardDrive, Network, RefreshCw, Power, PowerOff, AlertTriangle } from 'lucide-svelte';
|
||||||
|
import { t } from '$lib/i18n';
|
||||||
|
|
||||||
|
// LibraryFolder type matching Rust backend
|
||||||
|
interface LibraryFolder {
|
||||||
|
id: number;
|
||||||
|
path: string;
|
||||||
|
alias: string | null;
|
||||||
|
enabled: boolean;
|
||||||
|
isNetwork: boolean;
|
||||||
|
networkFsType: string | null;
|
||||||
|
userOverrideNetwork: boolean;
|
||||||
|
lastScan: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
isOpen: boolean;
|
||||||
|
folder: LibraryFolder | null;
|
||||||
|
onClose: () => void;
|
||||||
|
onSave: (folder: LibraryFolder) => void;
|
||||||
|
onScanFolder?: (folderId: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
isOpen,
|
||||||
|
folder,
|
||||||
|
onClose,
|
||||||
|
onSave,
|
||||||
|
onScanFolder
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
|
// Form state
|
||||||
|
let alias = $state('');
|
||||||
|
let enabled = $state(true);
|
||||||
|
let isNetwork = $state(false);
|
||||||
|
let networkFsType = $state('');
|
||||||
|
let userOverrideNetwork = $state(false);
|
||||||
|
let loading = $state(false);
|
||||||
|
let error = $state<string | null>(null);
|
||||||
|
let scanning = $state(false);
|
||||||
|
let accessible = $state(true);
|
||||||
|
let checkingAccessibility = $state(false);
|
||||||
|
|
||||||
|
// Network filesystem options
|
||||||
|
const networkFsOptions = [
|
||||||
|
{ value: '', label: $t('library.networkFs.auto') },
|
||||||
|
{ value: 'cifs', label: 'SMB/CIFS (Samba)' },
|
||||||
|
{ value: 'nfs', label: 'NFS' },
|
||||||
|
{ value: 'sshfs', label: 'SSHFS' },
|
||||||
|
{ value: 'rclone', label: 'rclone (Cloud)' },
|
||||||
|
{ value: 'webdav', label: 'WebDAV' },
|
||||||
|
{ value: 'glusterfs', label: 'GlusterFS' },
|
||||||
|
{ value: 'ceph', label: 'CephFS' },
|
||||||
|
{ value: 'other', label: $t('library.networkFs.other') }
|
||||||
|
];
|
||||||
|
|
||||||
|
// Reset form when modal opens
|
||||||
|
$effect(() => {
|
||||||
|
if (isOpen && folder) {
|
||||||
|
alias = folder.alias || '';
|
||||||
|
enabled = folder.enabled;
|
||||||
|
isNetwork = folder.isNetwork;
|
||||||
|
networkFsType = folder.networkFsType || '';
|
||||||
|
userOverrideNetwork = folder.userOverrideNetwork;
|
||||||
|
error = null;
|
||||||
|
loading = false;
|
||||||
|
scanning = false;
|
||||||
|
checkAccessibility();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
async function checkAccessibility() {
|
||||||
|
if (!folder) return;
|
||||||
|
|
||||||
|
checkingAccessibility = true;
|
||||||
|
try {
|
||||||
|
accessible = await invoke<boolean>('library_check_folder_accessible', { path: folder.path });
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to check folder accessibility:', err);
|
||||||
|
accessible = false;
|
||||||
|
} finally {
|
||||||
|
checkingAccessibility = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSave() {
|
||||||
|
if (!folder) return;
|
||||||
|
|
||||||
|
loading = true;
|
||||||
|
error = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updatedFolder = await invoke<LibraryFolder>('library_update_folder_settings', {
|
||||||
|
id: folder.id,
|
||||||
|
alias: alias.trim() || null,
|
||||||
|
enabled,
|
||||||
|
isNetwork,
|
||||||
|
networkFsType: isNetwork && networkFsType ? networkFsType : null,
|
||||||
|
userOverrideNetwork
|
||||||
|
});
|
||||||
|
onSave(updatedFolder);
|
||||||
|
onClose();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to update folder settings:', err);
|
||||||
|
error = String(err);
|
||||||
|
} finally {
|
||||||
|
loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleScanFolder() {
|
||||||
|
if (!folder || !onScanFolder) return;
|
||||||
|
|
||||||
|
scanning = true;
|
||||||
|
try {
|
||||||
|
onScanFolder(folder.id);
|
||||||
|
onClose();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to start folder scan:', err);
|
||||||
|
error = String(err);
|
||||||
|
} finally {
|
||||||
|
scanning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleNetworkToggle() {
|
||||||
|
isNetwork = !isNetwork;
|
||||||
|
userOverrideNetwork = true;
|
||||||
|
if (!isNetwork) {
|
||||||
|
networkFsType = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleKeydown(e: KeyboardEvent) {
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
onClose();
|
||||||
|
} else if (e.key === 'Enter' && !e.shiftKey) {
|
||||||
|
handleSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatLastScan(timestamp: number | null): string {
|
||||||
|
if (!timestamp) return $t('library.neverScanned');
|
||||||
|
const date = new Date(timestamp * 1000);
|
||||||
|
return date.toLocaleString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get display name for folder
|
||||||
|
function getDisplayName(): string {
|
||||||
|
if (!folder) return '';
|
||||||
|
if (folder.alias) return folder.alias;
|
||||||
|
// Get last part of path
|
||||||
|
const parts = folder.path.split('/').filter(Boolean);
|
||||||
|
return parts[parts.length - 1] || folder.path;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if isOpen && folder}
|
||||||
|
<div
|
||||||
|
class="modal-overlay"
|
||||||
|
onclick={() => onClose()}
|
||||||
|
onkeydown={handleKeydown}
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
tabindex="-1"
|
||||||
|
>
|
||||||
|
<div class="modal" onclick={(e) => e.stopPropagation()}>
|
||||||
|
<div class="modal-header">
|
||||||
|
<h2>{$t('library.folderSettings')}</h2>
|
||||||
|
<button class="close-btn" onclick={onClose}>
|
||||||
|
<X size={20} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-body">
|
||||||
|
{#if error}
|
||||||
|
<div class="error-message">{error}</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Folder path info -->
|
||||||
|
<div class="folder-info">
|
||||||
|
<div class="folder-icon">
|
||||||
|
{#if isNetwork}
|
||||||
|
<Network size={24} />
|
||||||
|
{:else}
|
||||||
|
<HardDrive size={24} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="folder-details">
|
||||||
|
<span class="folder-name">{getDisplayName()}</span>
|
||||||
|
<span class="folder-path">{folder.path}</span>
|
||||||
|
</div>
|
||||||
|
<div class="folder-status">
|
||||||
|
{#if checkingAccessibility}
|
||||||
|
<span class="status checking">
|
||||||
|
<RefreshCw size={14} class="spinning" />
|
||||||
|
</span>
|
||||||
|
{:else if accessible}
|
||||||
|
<span class="status accessible" title={$t('library.folderAccessible')}>
|
||||||
|
<Power size={14} />
|
||||||
|
</span>
|
||||||
|
{:else}
|
||||||
|
<span class="status inaccessible" title={$t('library.folderInaccessible')}>
|
||||||
|
<PowerOff size={14} />
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Alias -->
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="alias">{$t('library.folderAlias')}</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="alias"
|
||||||
|
bind:value={alias}
|
||||||
|
placeholder={$t('library.folderAliasPlaceholder')}
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
<span class="form-hint">{$t('library.folderAliasHint')}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Enabled toggle -->
|
||||||
|
<div class="form-group checkbox">
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
bind:checked={enabled}
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
<span>{$t('library.folderEnabled')}</span>
|
||||||
|
</label>
|
||||||
|
<span class="form-hint">{$t('library.folderEnabledHint')}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Network folder toggle -->
|
||||||
|
<div class="form-group checkbox">
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={isNetwork}
|
||||||
|
onchange={handleNetworkToggle}
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
<span class="network-label">
|
||||||
|
<Network size={14} />
|
||||||
|
{$t('library.isNetworkFolder')}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
{#if userOverrideNetwork}
|
||||||
|
<span class="form-hint override-hint">
|
||||||
|
<AlertTriangle size={12} />
|
||||||
|
{$t('library.networkOverrideHint')}
|
||||||
|
</span>
|
||||||
|
{:else}
|
||||||
|
<span class="form-hint">{$t('library.networkFolderHint')}</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Network filesystem type (only shown if network folder) -->
|
||||||
|
{#if isNetwork}
|
||||||
|
<div class="form-group network-fs-group">
|
||||||
|
<label for="network-fs">{$t('library.networkFsType')}</label>
|
||||||
|
<select
|
||||||
|
id="network-fs"
|
||||||
|
bind:value={networkFsType}
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
{#each networkFsOptions as option}
|
||||||
|
<option value={option.value}>{option.label}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
<span class="form-hint">{$t('library.networkFsTypeHint')}</span>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Last scan info -->
|
||||||
|
<div class="info-row">
|
||||||
|
<span class="info-label">{$t('library.lastScanned')}:</span>
|
||||||
|
<span class="info-value">{formatLastScan(folder.lastScan)}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button
|
||||||
|
class="btn-scan"
|
||||||
|
onclick={handleScanFolder}
|
||||||
|
disabled={loading || scanning || !enabled || !accessible}
|
||||||
|
title={!enabled ? $t('library.folderDisabledNoScan') : !accessible ? $t('library.folderInaccessibleNoScan') : ''}
|
||||||
|
>
|
||||||
|
<RefreshCw size={14} class={scanning ? 'spinning' : ''} />
|
||||||
|
{scanning ? $t('library.scanning') : $t('library.scanThisFolder')}
|
||||||
|
</button>
|
||||||
|
<div class="footer-spacer"></div>
|
||||||
|
<button class="btn-secondary" onclick={onClose} disabled={loading}>
|
||||||
|
{$t('common.cancel')}
|
||||||
|
</button>
|
||||||
|
<button class="btn-primary" onclick={handleSave} disabled={loading}>
|
||||||
|
{loading ? $t('common.saving') : $t('common.save')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.modal-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.7);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 480px;
|
||||||
|
max-height: 90vh;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid var(--bg-tertiary);
|
||||||
|
box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 20px 24px;
|
||||||
|
border-bottom: 1px solid var(--bg-tertiary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header h2 {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-btn {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: var(--text-muted);
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 4px;
|
||||||
|
transition: color 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-btn:hover {
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-body {
|
||||||
|
padding: 24px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-message {
|
||||||
|
background: rgba(239, 68, 68, 0.1);
|
||||||
|
border: 1px solid rgba(239, 68, 68, 0.3);
|
||||||
|
color: #ef4444;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 13px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-info {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 16px;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
border-radius: 12px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
border-radius: 10px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-details {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-name {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-path {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-status {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.checking {
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.accessible {
|
||||||
|
background: rgba(34, 197, 94, 0.1);
|
||||||
|
color: #22c55e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.inaccessible {
|
||||||
|
background: rgba(239, 68, 68, 0.1);
|
||||||
|
color: #ef4444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group label {
|
||||||
|
display: block;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group input[type="text"],
|
||||||
|
.form-group select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px 12px;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
border: 1px solid var(--bg-tertiary);
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
transition: border-color 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group select {
|
||||||
|
appearance: none;
|
||||||
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: right 12px center;
|
||||||
|
padding-right: 36px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group input[type="text"]:focus,
|
||||||
|
.form-group select:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--accent-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-hint {
|
||||||
|
display: block;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.override-hint {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
color: var(--text-warning, #f59e0b);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group.checkbox label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group.checkbox input[type="checkbox"] {
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
accent-color: var(--accent-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group.checkbox span {
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.network-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.network-fs-group {
|
||||||
|
margin-left: 28px;
|
||||||
|
padding-left: 16px;
|
||||||
|
border-left: 2px solid var(--bg-tertiary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 10px 0;
|
||||||
|
border-top: 1px solid var(--bg-tertiary);
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-label {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-value {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-footer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 16px 24px;
|
||||||
|
border-top: 1px solid var(--bg-tertiary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-spacer {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-scan {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 10px 16px;
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-primary);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-scan:hover:not(:disabled) {
|
||||||
|
background: var(--bg-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-scan:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary,
|
||||||
|
.btn-primary {
|
||||||
|
padding: 10px 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--text-muted);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary:hover:not(:disabled) {
|
||||||
|
border-color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background: var(--accent-primary);
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover:not(:disabled) {
|
||||||
|
background: var(--accent-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary:disabled,
|
||||||
|
.btn-primary:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
from { transform: rotate(0deg); }
|
||||||
|
to { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.spinning) {
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -4,8 +4,11 @@
|
|||||||
import { onMount, onDestroy } from 'svelte';
|
import { onMount, onDestroy } from 'svelte';
|
||||||
import {
|
import {
|
||||||
HardDrive, Music, Disc3, Mic2, FolderPlus, Trash2, RefreshCw,
|
HardDrive, Music, Disc3, Mic2, FolderPlus, Trash2, RefreshCw,
|
||||||
Settings, ArrowLeft, X, Play, AlertCircle, ImageDown, Upload, Search, LayoutGrid, List, Edit3
|
Settings, ArrowLeft, X, Play, AlertCircle, ImageDown, Upload, Search, LayoutGrid, List, Edit3,
|
||||||
|
Network, Power, PowerOff
|
||||||
} from 'lucide-svelte';
|
} from 'lucide-svelte';
|
||||||
|
import FolderSettingsModal from '../FolderSettingsModal.svelte';
|
||||||
|
import { t } from '$lib/i18n';
|
||||||
import AlbumCard from '../AlbumCard.svelte';
|
import AlbumCard from '../AlbumCard.svelte';
|
||||||
import TrackRow from '../TrackRow.svelte';
|
import TrackRow from '../TrackRow.svelte';
|
||||||
import {
|
import {
|
||||||
@@ -99,6 +102,17 @@
|
|||||||
errors: { file_path: string; error: string }[];
|
errors: { file_path: string; error: string }[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface LibraryFolder {
|
||||||
|
id: number;
|
||||||
|
path: string;
|
||||||
|
alias: string | null;
|
||||||
|
enabled: boolean;
|
||||||
|
isNetwork: boolean;
|
||||||
|
networkFsType: string | null;
|
||||||
|
userOverrideNetwork: boolean;
|
||||||
|
lastScan: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onAlbumClick?: (album: LocalAlbum) => void;
|
onAlbumClick?: (album: LocalAlbum) => void;
|
||||||
onQobuzArtistClick?: (artistId: number) => void;
|
onQobuzArtistClick?: (artistId: number) => void;
|
||||||
@@ -144,7 +158,7 @@
|
|||||||
let artists = $state<LocalArtist[]>([]);
|
let artists = $state<LocalArtist[]>([]);
|
||||||
let tracks = $state<LocalTrack[]>([]);
|
let tracks = $state<LocalTrack[]>([]);
|
||||||
let stats = $state<LibraryStats | null>(null);
|
let stats = $state<LibraryStats | null>(null);
|
||||||
let folders = $state<string[]>([]);
|
let folders = $state<LibraryFolder[]>([]);
|
||||||
let scanProgress = $state<ScanProgress | null>(null);
|
let scanProgress = $state<ScanProgress | null>(null);
|
||||||
|
|
||||||
// Loading state
|
// Loading state
|
||||||
@@ -168,8 +182,15 @@
|
|||||||
let editingAlbumTitle = $state('');
|
let editingAlbumTitle = $state('');
|
||||||
let editingAlbumHidden = $state(false);
|
let editingAlbumHidden = $state(false);
|
||||||
|
|
||||||
// Folder selection state
|
// Folder selection state (by folder ID)
|
||||||
let selectedFolders = $state<Set<string>>(new Set());
|
let selectedFolders = $state<Set<number>>(new Set());
|
||||||
|
|
||||||
|
// Folder settings modal state
|
||||||
|
let showFolderSettingsModal = $state(false);
|
||||||
|
let editingFolder = $state<LibraryFolder | null>(null);
|
||||||
|
|
||||||
|
// Folder accessibility cache
|
||||||
|
let folderAccessibility = $state<Map<number, boolean>>(new Map());
|
||||||
|
|
||||||
let unsubscribeNav: (() => void) | null = null;
|
let unsubscribeNav: (() => void) | null = null;
|
||||||
let unsubscribeOffline: (() => void) | null = null;
|
let unsubscribeOffline: (() => void) | null = null;
|
||||||
@@ -272,12 +293,33 @@
|
|||||||
|
|
||||||
async function loadFolders() {
|
async function loadFolders() {
|
||||||
try {
|
try {
|
||||||
folders = await invoke<string[]>('library_get_folders');
|
folders = await invoke<LibraryFolder[]>('library_get_folders_with_metadata');
|
||||||
|
// Check accessibility for network folders
|
||||||
|
for (const folder of folders) {
|
||||||
|
if (folder.isNetwork) {
|
||||||
|
checkFolderAccessibility(folder);
|
||||||
|
} else {
|
||||||
|
folderAccessibility.set(folder.id, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
folderAccessibility = new Map(folderAccessibility);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to load folders:', err);
|
console.error('Failed to load folders:', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkFolderAccessibility(folder: LibraryFolder) {
|
||||||
|
try {
|
||||||
|
const accessible = await invoke<boolean>('library_check_folder_accessible', { path: folder.path });
|
||||||
|
folderAccessibility.set(folder.id, accessible);
|
||||||
|
folderAccessibility = new Map(folderAccessibility);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to check folder accessibility:', err);
|
||||||
|
folderAccessibility.set(folder.id, false);
|
||||||
|
folderAccessibility = new Map(folderAccessibility);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function loadArtists() {
|
async function loadArtists() {
|
||||||
loading = true;
|
loading = true;
|
||||||
try {
|
try {
|
||||||
@@ -340,21 +382,27 @@
|
|||||||
|
|
||||||
if (!selected || typeof selected !== 'string') return;
|
if (!selected || typeof selected !== 'string') return;
|
||||||
|
|
||||||
await invoke('library_add_folder', { path: selected });
|
const newFolder = await invoke<LibraryFolder>('library_add_folder', { path: selected });
|
||||||
await loadFolders();
|
await loadFolders();
|
||||||
|
|
||||||
|
// Show warning if network folder detected
|
||||||
|
if (newFolder.isNetwork) {
|
||||||
|
alert($t('library.networkFolderDetected'));
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to add folder:', err);
|
console.error('Failed to add folder:', err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleRemoveFolder(path: string) {
|
async function handleRemoveFolder(folder: LibraryFolder) {
|
||||||
if (!confirm(`Remove "${path}" from library? This will remove all indexed tracks from this folder.`)) {
|
const displayName = folder.alias || folder.path;
|
||||||
|
if (!confirm(`Remove "${displayName}" from library? This will remove all indexed tracks from this folder.`)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await invoke('library_remove_folder', { path });
|
await invoke('library_remove_folder', { path: folder.path });
|
||||||
selectedFolders.delete(path);
|
selectedFolders.delete(folder.id);
|
||||||
selectedFolders = new Set(selectedFolders);
|
selectedFolders = new Set(selectedFolders);
|
||||||
await loadFolders();
|
await loadFolders();
|
||||||
await loadLibraryData();
|
await loadLibraryData();
|
||||||
@@ -364,24 +412,67 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleFolderSelection(folder: string) {
|
function toggleFolderSelection(folderId: number) {
|
||||||
if (selectedFolders.has(folder)) {
|
if (selectedFolders.has(folderId)) {
|
||||||
selectedFolders.delete(folder);
|
selectedFolders.delete(folderId);
|
||||||
} else {
|
} else {
|
||||||
selectedFolders.add(folder);
|
selectedFolders.add(folderId);
|
||||||
}
|
}
|
||||||
selectedFolders = new Set(selectedFolders);
|
selectedFolders = new Set(selectedFolders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleEditFolder() {
|
||||||
|
if (selectedFolders.size !== 1) return;
|
||||||
|
const folderId = Array.from(selectedFolders)[0];
|
||||||
|
editingFolder = folders.find(f => f.id === folderId) || null;
|
||||||
|
if (editingFolder) {
|
||||||
|
showFolderSettingsModal = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFolderSettingsSave(updatedFolder: LibraryFolder) {
|
||||||
|
// Update folder in list
|
||||||
|
const index = folders.findIndex(f => f.id === updatedFolder.id);
|
||||||
|
if (index !== -1) {
|
||||||
|
folders[index] = updatedFolder;
|
||||||
|
folders = [...folders];
|
||||||
|
}
|
||||||
|
editingFolder = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleScanSingleFolder(folderId: number) {
|
||||||
|
try {
|
||||||
|
scanning = true;
|
||||||
|
await invoke('library_scan_folder', { folderId });
|
||||||
|
// Start polling for progress
|
||||||
|
const progressInterval = setInterval(async () => {
|
||||||
|
scanProgress = await invoke<ScanProgress>('library_get_scan_progress');
|
||||||
|
if (scanProgress.status === 'Complete' || scanProgress.status === 'Cancelled' || scanProgress.status === 'Error') {
|
||||||
|
clearInterval(progressInterval);
|
||||||
|
scanning = false;
|
||||||
|
await loadLibraryData();
|
||||||
|
await loadFolders();
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to scan folder:', err);
|
||||||
|
scanning = false;
|
||||||
|
alert(`Failed to scan folder: ${err}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function handleRemoveSelectedFolders() {
|
async function handleRemoveSelectedFolders() {
|
||||||
if (selectedFolders.size === 0) return;
|
if (selectedFolders.size === 0) return;
|
||||||
|
|
||||||
const count = selectedFolders.size;
|
const count = selectedFolders.size;
|
||||||
if (!confirm(`Remove ${count} selected folder${count > 1 ? 's' : ''}? This will remove all indexed tracks from these folders.`)) return;
|
if (!confirm(`Remove ${count} selected folder${count > 1 ? 's' : ''}? This will remove all indexed tracks from these folders.`)) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const folder of selectedFolders) {
|
for (const folderId of selectedFolders) {
|
||||||
await invoke('library_remove_folder', { path: folder });
|
const folder = folders.find(f => f.id === folderId);
|
||||||
|
if (folder) {
|
||||||
|
await invoke('library_remove_folder', { path: folder.path });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
selectedFolders.clear();
|
selectedFolders.clear();
|
||||||
selectedFolders = new Set(selectedFolders);
|
selectedFolders = new Set(selectedFolders);
|
||||||
@@ -1368,16 +1459,24 @@
|
|||||||
{#if showSettings}
|
{#if showSettings}
|
||||||
<div class="settings-panel">
|
<div class="settings-panel">
|
||||||
<div class="settings-header">
|
<div class="settings-header">
|
||||||
<h3>Library Folders</h3>
|
<h3>{$t('library.folders')}</h3>
|
||||||
<div class="folder-actions">
|
<div class="folder-actions">
|
||||||
<button class="icon-btn" onclick={handleAddFolder} title="Add folder">
|
<button class="icon-btn" onclick={handleAddFolder} title={$t('library.addFolder')}>
|
||||||
<FolderPlus size={16} />
|
<FolderPlus size={16} />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="icon-btn"
|
class="icon-btn"
|
||||||
onclick={handleRemoveSelectedFolders}
|
onclick={handleEditFolder}
|
||||||
|
disabled={selectedFolders.size !== 1}
|
||||||
|
title={selectedFolders.size === 1 ? $t('library.editFolder') : $t('library.editFolderHint')}
|
||||||
|
>
|
||||||
|
<Edit3 size={16} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="icon-btn"
|
||||||
|
onclick={handleRemoveSelectedFolders}
|
||||||
disabled={selectedFolders.size === 0}
|
disabled={selectedFolders.size === 0}
|
||||||
title="Remove selected folders"
|
title={$t('library.removeSelectedFolders')}
|
||||||
>
|
>
|
||||||
<Trash2 size={16} />
|
<Trash2 size={16} />
|
||||||
</button>
|
</button>
|
||||||
@@ -1386,20 +1485,45 @@
|
|||||||
|
|
||||||
{#if folders.length === 0}
|
{#if folders.length === 0}
|
||||||
<div class="no-folders">
|
<div class="no-folders">
|
||||||
<p>No folders added yet. Add a folder to start building your library.</p>
|
<p>{$t('library.noFolders')}</p>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="folder-table">
|
<div class="folder-table">
|
||||||
{#each folders as folder}
|
{#each folders as folder (folder.id)}
|
||||||
<div class="folder-row" class:selected={selectedFolders.has(folder)}>
|
{@const accessible = folderAccessibility.get(folder.id) ?? true}
|
||||||
|
<div
|
||||||
|
class="folder-row"
|
||||||
|
class:selected={selectedFolders.has(folder.id)}
|
||||||
|
class:disabled={!folder.enabled}
|
||||||
|
class:inaccessible={!accessible}
|
||||||
|
>
|
||||||
<label class="folder-checkbox">
|
<label class="folder-checkbox">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={selectedFolders.has(folder)}
|
checked={selectedFolders.has(folder.id)}
|
||||||
onchange={() => toggleFolderSelection(folder)}
|
onchange={() => toggleFolderSelection(folder.id)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<span class="folder-path">{folder}</span>
|
<div class="folder-icon">
|
||||||
|
{#if folder.isNetwork}
|
||||||
|
<Network size={14} class={accessible ? 'network-connected' : 'network-disconnected'} />
|
||||||
|
{:else}
|
||||||
|
<HardDrive size={14} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="folder-info">
|
||||||
|
{#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}
|
||||||
|
</div>
|
||||||
|
{#if !folder.enabled}
|
||||||
|
<span class="folder-badge disabled-badge">{$t('library.disabled')}</span>
|
||||||
|
{:else if folder.isNetwork && !accessible}
|
||||||
|
<span class="folder-badge offline-badge">{$t('library.unavailable')}</span>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
@@ -2014,6 +2138,15 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<!-- Folder Settings Modal -->
|
||||||
|
<FolderSettingsModal
|
||||||
|
isOpen={showFolderSettingsModal}
|
||||||
|
folder={editingFolder}
|
||||||
|
onClose={() => { showFolderSettingsModal = false; editingFolder = null; }}
|
||||||
|
onSave={handleFolderSettingsSave}
|
||||||
|
onScanFolder={handleScanSingleFolder}
|
||||||
|
/>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.library-view {
|
.library-view {
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
@@ -2253,6 +2386,73 @@
|
|||||||
background: rgba(59, 130, 246, 0.2);
|
background: rgba(59, 130, 246, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.folder-row.disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-row.inaccessible {
|
||||||
|
border-left: 3px solid #ef4444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-icon {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-icon :global(.network-connected) {
|
||||||
|
color: #22c55e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-icon :global(.network-disconnected) {
|
||||||
|
color: #ef4444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-alias {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-path-small {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-family: var(--font-mono, 'Courier New', monospace);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-badge {
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disabled-badge {
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.offline-badge {
|
||||||
|
background: rgba(239, 68, 68, 0.1);
|
||||||
|
color: #ef4444;
|
||||||
|
}
|
||||||
|
|
||||||
.folder-checkbox {
|
.folder-checkbox {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -65,19 +65,23 @@
|
|||||||
"albums": "Albums",
|
"albums": "Albums",
|
||||||
"artists": "Artists",
|
"artists": "Artists",
|
||||||
"tracks": "Tracks",
|
"tracks": "Tracks",
|
||||||
"folders": "Folders",
|
"folders": "Library Folders",
|
||||||
"noAlbums": "No albums in library",
|
"noAlbums": "No albums in library",
|
||||||
"noArtists": "No artists in library",
|
"noArtists": "No artists in library",
|
||||||
"noTracks": "No tracks in library",
|
"noTracks": "No tracks in library",
|
||||||
"noFolders": "No folders added",
|
"noFolders": "No folders added yet. Add a folder to start building your library.",
|
||||||
"addFolder": "Add Folder",
|
"addFolder": "Add Folder",
|
||||||
"removeFolder": "Remove",
|
"removeFolder": "Remove",
|
||||||
|
"editFolder": "Edit Folder",
|
||||||
|
"editFolderHint": "Select exactly one folder to edit",
|
||||||
|
"removeSelectedFolders": "Remove selected folders",
|
||||||
"scan": "Scan",
|
"scan": "Scan",
|
||||||
"scanning": "Scanning...",
|
"scanning": "Scanning...",
|
||||||
"stopScan": "Stop",
|
"stopScan": "Stop",
|
||||||
"scanComplete": "Scan complete",
|
"scanComplete": "Scan complete",
|
||||||
"scanCancelled": "Scan cancelled",
|
"scanCancelled": "Scan cancelled",
|
||||||
"scanError": "Scan error",
|
"scanError": "Scan error",
|
||||||
|
"scanThisFolder": "Scan This Folder",
|
||||||
"searchPlaceholder": "Search...",
|
"searchPlaceholder": "Search...",
|
||||||
"searchAlbums": "Search albums...",
|
"searchAlbums": "Search albums...",
|
||||||
"searchArtists": "Search artists...",
|
"searchArtists": "Search artists...",
|
||||||
@@ -90,7 +94,31 @@
|
|||||||
"viewAs": "View as",
|
"viewAs": "View as",
|
||||||
"grid": "Grid",
|
"grid": "Grid",
|
||||||
"list": "List",
|
"list": "List",
|
||||||
"fetchingArtwork": "Fetching artwork..."
|
"fetchingArtwork": "Fetching artwork...",
|
||||||
|
"folderSettings": "Folder Settings",
|
||||||
|
"folderAlias": "Alias",
|
||||||
|
"folderAliasPlaceholder": "My Music, NAS, etc.",
|
||||||
|
"folderAliasHint": "A friendly name to identify this folder",
|
||||||
|
"folderEnabled": "Enabled",
|
||||||
|
"folderEnabledHint": "Disabled folders won't be scanned and their content won't appear in the library",
|
||||||
|
"isNetworkFolder": "Network Folder",
|
||||||
|
"networkFolderHint": "Detected automatically. Enable if this is a network location (NAS, shared drive, etc.)",
|
||||||
|
"networkOverrideHint": "You have manually changed this setting",
|
||||||
|
"networkFsType": "Filesystem Type",
|
||||||
|
"networkFsTypeHint": "Usually detected automatically. Set manually if needed.",
|
||||||
|
"lastScanned": "Last scanned",
|
||||||
|
"neverScanned": "Never",
|
||||||
|
"folderAccessible": "Folder is accessible",
|
||||||
|
"folderInaccessible": "Folder is not accessible",
|
||||||
|
"folderDisabledNoScan": "Enable the folder first to scan",
|
||||||
|
"folderInaccessibleNoScan": "Folder is not accessible",
|
||||||
|
"networkFolderDetected": "This folder appears to be on a network drive. It may be unavailable in offline mode.",
|
||||||
|
"disabled": "Disabled",
|
||||||
|
"unavailable": "Unavailable",
|
||||||
|
"networkFs": {
|
||||||
|
"auto": "Auto-detect",
|
||||||
|
"other": "Other"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"album": {
|
"album": {
|
||||||
"tracks": "tracks",
|
"tracks": "tracks",
|
||||||
|
|||||||
@@ -65,19 +65,23 @@
|
|||||||
"albums": "Álbumes",
|
"albums": "Álbumes",
|
||||||
"artists": "Artistas",
|
"artists": "Artistas",
|
||||||
"tracks": "Pistas",
|
"tracks": "Pistas",
|
||||||
"folders": "Carpetas",
|
"folders": "Carpetas de la Biblioteca",
|
||||||
"noAlbums": "No hay álbumes en la biblioteca",
|
"noAlbums": "No hay álbumes en la biblioteca",
|
||||||
"noArtists": "No hay artistas en la biblioteca",
|
"noArtists": "No hay artistas en la biblioteca",
|
||||||
"noTracks": "No hay pistas en la biblioteca",
|
"noTracks": "No hay pistas en la biblioteca",
|
||||||
"noFolders": "No hay carpetas agregadas",
|
"noFolders": "No hay carpetas agregadas. Agrega una carpeta para comenzar a construir tu biblioteca.",
|
||||||
"addFolder": "Agregar Carpeta",
|
"addFolder": "Agregar Carpeta",
|
||||||
"removeFolder": "Eliminar",
|
"removeFolder": "Eliminar",
|
||||||
|
"editFolder": "Editar Carpeta",
|
||||||
|
"editFolderHint": "Selecciona exactamente una carpeta para editar",
|
||||||
|
"removeSelectedFolders": "Eliminar carpetas seleccionadas",
|
||||||
"scan": "Escanear",
|
"scan": "Escanear",
|
||||||
"scanning": "Escaneando...",
|
"scanning": "Escaneando...",
|
||||||
"stopScan": "Detener",
|
"stopScan": "Detener",
|
||||||
"scanComplete": "Escaneo completo",
|
"scanComplete": "Escaneo completo",
|
||||||
"scanCancelled": "Escaneo cancelado",
|
"scanCancelled": "Escaneo cancelado",
|
||||||
"scanError": "Error de escaneo",
|
"scanError": "Error de escaneo",
|
||||||
|
"scanThisFolder": "Escanear Esta Carpeta",
|
||||||
"searchPlaceholder": "Buscar...",
|
"searchPlaceholder": "Buscar...",
|
||||||
"searchAlbums": "Buscar álbumes...",
|
"searchAlbums": "Buscar álbumes...",
|
||||||
"searchArtists": "Buscar artistas...",
|
"searchArtists": "Buscar artistas...",
|
||||||
@@ -90,7 +94,31 @@
|
|||||||
"viewAs": "Ver como",
|
"viewAs": "Ver como",
|
||||||
"grid": "Cuadrícula",
|
"grid": "Cuadrícula",
|
||||||
"list": "Lista",
|
"list": "Lista",
|
||||||
"fetchingArtwork": "Obteniendo portada..."
|
"fetchingArtwork": "Obteniendo portada...",
|
||||||
|
"folderSettings": "Configuración de Carpeta",
|
||||||
|
"folderAlias": "Alias",
|
||||||
|
"folderAliasPlaceholder": "Mi Música, NAS, etc.",
|
||||||
|
"folderAliasHint": "Un nombre descriptivo para identificar esta carpeta",
|
||||||
|
"folderEnabled": "Habilitada",
|
||||||
|
"folderEnabledHint": "Las carpetas deshabilitadas no se escanearán y su contenido no aparecerá en la biblioteca",
|
||||||
|
"isNetworkFolder": "Carpeta de Red",
|
||||||
|
"networkFolderHint": "Detectado automáticamente. Activa si es una ubicación de red (NAS, disco compartido, etc.)",
|
||||||
|
"networkOverrideHint": "Has cambiado esta configuración manualmente",
|
||||||
|
"networkFsType": "Tipo de Sistema de Archivos",
|
||||||
|
"networkFsTypeHint": "Generalmente se detecta automáticamente. Configura manualmente si es necesario.",
|
||||||
|
"lastScanned": "Último escaneo",
|
||||||
|
"neverScanned": "Nunca",
|
||||||
|
"folderAccessible": "La carpeta es accesible",
|
||||||
|
"folderInaccessible": "La carpeta no es accesible",
|
||||||
|
"folderDisabledNoScan": "Habilita la carpeta primero para escanear",
|
||||||
|
"folderInaccessibleNoScan": "La carpeta no es accesible",
|
||||||
|
"networkFolderDetected": "Esta carpeta parece estar en una unidad de red. Puede no estar disponible en modo offline.",
|
||||||
|
"disabled": "Deshabilitada",
|
||||||
|
"unavailable": "No disponible",
|
||||||
|
"networkFs": {
|
||||||
|
"auto": "Auto-detectar",
|
||||||
|
"other": "Otro"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"album": {
|
"album": {
|
||||||
"tracks": "pistas",
|
"tracks": "pistas",
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 256 256" enable-background="new 0 0 256 256" xml:space="preserve">
|
||||||
|
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
|
||||||
|
<g><g><g><path fill="#000000" d="M26.8,10.4c-8.2,1.2-15.1,8.2-16.3,16.7C10.3,28.7,10,38.7,10,49.4v19.5h98.2h98.2V47.8c0-19.9,0-21.3-0.9-24.1c-1.7-5.5-6-10-12-12.4l-2.5-1l-80.9,0C65.6,10.1,28.1,10.2,26.8,10.4z M88.9,39.4v10.1H64.2H39.5V39.4V29.3h24.7h24.7V39.4z M140.4,29.8c2.7,0.7,5,2.7,6.3,5.2c1.5,3.1,1.5,5.9,0,9c-3.4,6.8-12.9,7.4-17.1,1c-1.2-1.7-1.3-2.4-1.3-5.5c0-3.1,0.2-3.8,1.2-5.4C132,30.3,136.4,28.6,140.4,29.8z M169.9,29.8c2.7,0.7,5,2.7,6.3,5.2c1.5,3.1,1.5,5.9,0,9c-3.4,6.8-12.9,7.4-17.1,1c-1.2-1.7-1.3-2.4-1.3-5.5c0-3.1,0.2-3.8,1.2-5.4C161.5,30.3,165.9,28.6,169.9,29.8z"/><path fill="#000000" d="M10,108.3v29.3h57.5h57.6l6.2-6.1c4.3-4.3,7.7-7.1,11.2-9.5c4.7-3.1,14.5-8.3,15.8-8.3c0.7,0,0.7,0-0.2-1.8c-1.1-2.2-0.7-6.8,0.7-9c2.5-3.7,7.5-5.4,11.8-4c3.4,1.1,6.6,5.2,6.7,8.3v1.2h9.1c8.7,0,10.9,0.2,18.7,1.9l1.2,0.3V94.8V79.1h-98.2H10V108.3z M88.9,108.3v9.9H64.2H39.5v-9.9v-9.9h24.7h24.7V108.3z M142.2,99.3c6.2,3.2,7.5,11.1,2.6,15.9c-4.9,4.9-12.7,3.6-15.9-2.6c-1.1-2-1.2-6.1-0.2-8.3c0.7-1.9,3.3-4.4,5.1-5.2C135.9,98.1,140.2,98.3,142.2,99.3z"/><path fill="#000000" d="M177.3,133.4v5.4l-3.8,1.1c-2.1,0.6-6.1,2.2-8.8,3.6l-5,2.5l-3.8-3.7l-3.7-3.7l-6.8,6.8l-6.8,6.8l3.7,3.7l3.7,3.7l-2.5,5c-1.4,2.8-3,6.7-3.6,8.8l-1.1,3.8h-5.4H128v9.7v9.7h5.4h5.4l1.1,3.8c0.6,2.1,2.2,6.1,3.6,8.8l2.5,5l-3.7,3.7l-3.8,3.8l6.8,6.8l6.8,6.8l3.8-3.8l3.7-3.7l5,2.5c2.7,1.4,6.7,3,8.8,3.6l3.8,1.1v5.4v5.4h9.7h9.7v-5.5v-5.5l1.5-0.3c3.1-0.7,7.1-2.3,11.5-4.5l4.5-2.3l3.8,3.8l3.8,3.8l6.8-6.8l6.8-6.8l-3.7-3.7l-3.8-3.8l2.8-5.7c1.6-3.1,3.2-7.1,3.6-8.8l0.7-3.1h5.5h5.5v-9.7v-9.7h-5.5H235l-0.3-1.5c-0.7-3.1-2.3-7.1-4.5-11.5l-2.4-4.5l3.8-3.8l3.8-3.8l-6.8-6.8l-6.8-6.8l-3.7,3.7c-2,2-3.8,3.7-4.1,3.7s-1.6-0.7-3-1.5c-3.3-1.9-8.8-4.2-11.9-4.9l-2.4-0.6v-5.5v-5.5H187h-9.7V133.4z M191.9,167.7c8.7,2.3,14.9,10.3,14.9,19.2c0,12.8-12.5,22.4-24.7,19.2c-11.8-3.1-18.2-16.4-13.1-27.3c2.4-5.3,8-10,13.2-11.2C184.9,166.9,189.3,167,191.9,167.7z"/><path fill="#000000" d="M10.1,169.3c0.1,21.2,0.2,21.6,1.2,24.2c2.3,5.7,7,10.2,12.4,11.9c2.9,0.9,4.2,0.9,44.9,0.9h42l-0.4-1.5c-2.6-12.4-2.7-24-0.1-35.1c1.3-5.7,3.7-12.5,6.2-17.3c1.1-2.3,2-4.2,2-4.3c0-0.1-24.4-0.2-54.2-0.2H10L10.1,169.3z M88.9,177v9.9H64.2H39.5V177v-9.9h24.7h24.7V177z"/></g></g></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 256 256" enable-background="new 0 0 256 256" xml:space="preserve">
|
||||||
|
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
|
||||||
|
<g><g><g><path fill="#000000" d="M49.5,10.7c-4.6,1.6-7.9,5-9.4,9.6c-0.7,2-0.7,9-0.6,71.5l0.1,69.2l1.2,2.6c1.5,3.1,3.8,5.5,7,7.2l2.4,1.2h77.3c75.2,0,77.4,0,79.6-0.9c3-1.2,6.8-4.8,8.1-7.8l1.1-2.4v-55.4V50.3l-1.2-2.4c-1.7-3.2-4.1-5.5-7.2-7l-2.6-1.2l-39.2-0.1l-39.3-0.1l-5.4-11c-5.9-12-7.6-14.5-11.6-16.4c-4.2-2-6.4-2.1-33.1-2.1C55.1,10,51.3,10.1,49.5,10.7z"/><path fill="#000000" d="M113.2,202v14.8L67,216.8L20.7,217l-2.3,1.2c-3,1.4-5.7,4.2-7.2,7.2c-1.6,3.3-1.6,9.1,0,12.5c1.4,3,4.2,5.7,7.2,7.2l2.3,1.2H128h107.3l2.3-1.2c3-1.4,5.7-4.2,7.2-7.2c1.6-3.3,1.6-9.1,0-12.5c-1.4-3-4.2-5.7-7.2-7.2l-2.3-1.2l-46.3-0.1l-46.3-0.1V202v-14.8H128h-14.8V202z"/></g></g></g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
Reference in new issue
Block a user