mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-11-03 22:05:11 -05:00
- Added a new "Open Library" menu item to the application, allowing users to select a library folder. - Implemented the backend logic to handle library opening, including JSON-RPC requests to the daemon. - Introduced a filesystem watcher in the LibraryManager to monitor library directory changes, enabling automatic opening and closing of libraries based on filesystem events. - Enhanced error handling for library operations and added relevant logging for better traceability. - Updated the LibraryError enum to include filesystem watcher errors, improving error reporting.
69 lines
1.6 KiB
Rust
69 lines
1.6 KiB
Rust
//! Library-specific error types
|
|
|
|
use std::path::PathBuf;
|
|
use thiserror::Error;
|
|
use uuid::Uuid;
|
|
|
|
/// Library operation errors
|
|
#[derive(Error, Debug)]
|
|
pub enum LibraryError {
|
|
/// Library is already open
|
|
#[error("Library {0} is already open")]
|
|
AlreadyOpen(Uuid),
|
|
|
|
/// Library is already in use by another process
|
|
#[error("Library is already in use by another process")]
|
|
AlreadyInUse,
|
|
|
|
/// Stale lock file detected
|
|
#[error("Stale lock file detected - library may have crashed previously")]
|
|
StaleLock,
|
|
|
|
/// Not a valid library directory
|
|
#[error("Not a valid library directory: {0}")]
|
|
NotALibrary(PathBuf),
|
|
|
|
/// Library not found
|
|
#[error("Library not found: {0}")]
|
|
NotFound(String),
|
|
|
|
/// Invalid library name
|
|
#[error("Invalid library name: {0}")]
|
|
InvalidName(String),
|
|
|
|
/// Library already exists
|
|
#[error("Library already exists at: {0}")]
|
|
AlreadyExists(PathBuf),
|
|
|
|
/// Configuration error
|
|
#[error("Configuration error: {0}")]
|
|
ConfigError(String),
|
|
|
|
/// Database error
|
|
#[error("Database error: {0}")]
|
|
DatabaseError(#[from] sea_orm::DbErr),
|
|
|
|
/// IO error
|
|
#[error("IO error: {0}")]
|
|
IoError(#[from] std::io::Error),
|
|
|
|
/// JSON error
|
|
#[error("JSON error: {0}")]
|
|
JsonError(#[from] serde_json::Error),
|
|
|
|
/// Job system error
|
|
#[error("Job system error: {0}")]
|
|
JobError(#[from] crate::infra::job::error::JobError),
|
|
|
|
/// Filesystem watcher error
|
|
#[error("Filesystem watcher error: {0}")]
|
|
WatcherError(#[from] notify::Error),
|
|
|
|
/// Generic error
|
|
#[error("{0}")]
|
|
Other(String),
|
|
}
|
|
|
|
/// Result type for library operations
|
|
pub type Result<T> = std::result::Result<T, LibraryError>;
|