add per-user isolation support to all remaining modules
Add new_at() constructors, Option<Store> wrappers, new_empty()/init_at()/ teardown() methods, and update all commands to unwrap Option for: - config: audio_settings, download_settings, favorites_cache, favorites_preferences, legal_settings, playback_preferences, remote_control_settings, subscription_state, tray_settings - data: api_cache, artist_blacklist, artist_vectors, library, listenbrainz, lyrics, musicbrainz, offline, offline_cache, radio_engine, reco_store, updates
This commit is contained in:
1 parent
48dac0ec3a
commit
aab3e67641
29 files changed
+1174
-429
No files matched your search
@@ -26,7 +26,7 @@ pub use models::*;
|
||||
pub use tag_sidecar::*;
|
||||
pub use scanner::{LibraryScanner, ScanResult};
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
@@ -56,7 +56,30 @@ pub fn init_library_state() -> Result<LibraryState, LibraryError> {
|
||||
let db = LibraryDatabase::open(&db_path)?;
|
||||
|
||||
Ok(LibraryState {
|
||||
db: Arc::new(Mutex::new(db)),
|
||||
db: Arc::new(Mutex::new(Some(db))),
|
||||
scan_progress: Arc::new(Mutex::new(ScanProgress::default())),
|
||||
scan_cancel: Arc::new(AtomicBool::new(false)),
|
||||
})
|
||||
}
|
||||
|
||||
/// Initialize library state with no database (for deferred init)
|
||||
pub fn init_library_state_empty() -> LibraryState {
|
||||
LibraryState {
|
||||
db: Arc::new(Mutex::new(None)),
|
||||
scan_progress: Arc::new(Mutex::new(ScanProgress::default())),
|
||||
scan_cancel: Arc::new(AtomicBool::new(false)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize library state at a specific directory
|
||||
pub fn init_library_state_at(base_dir: &Path) -> Result<LibraryState, LibraryError> {
|
||||
std::fs::create_dir_all(base_dir)
|
||||
.map_err(|e| LibraryError::Database(format!("Failed to create directory: {}", e)))?;
|
||||
let db_path = base_dir.join("library.db");
|
||||
let db = LibraryDatabase::open(&db_path)?;
|
||||
|
||||
Ok(LibraryState {
|
||||
db: Arc::new(Mutex::new(Some(db))),
|
||||
scan_progress: Arc::new(Mutex::new(ScanProgress::default())),
|
||||
scan_cancel: Arc::new(AtomicBool::new(false)),
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user