chore: bump deps; fix clippy lints & cleanup
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I4c4815ad145650a07f108614034d2e996a6a6964
This commit is contained in:
parent
c535650f45
commit
cd1161ee5d
41 changed files with 1528 additions and 953 deletions
|
|
@ -13,6 +13,7 @@ use tracing::{info, warn};
|
|||
|
||||
use crate::{error::Result, import, storage::DynStorageBackend};
|
||||
|
||||
/// Status of a directory scan operation.
|
||||
pub struct ScanStatus {
|
||||
pub scanning: bool,
|
||||
pub files_found: usize,
|
||||
|
|
@ -100,6 +101,17 @@ impl Default for ScanProgress {
|
|||
}
|
||||
}
|
||||
|
||||
/// Scans a directory with default options.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `storage` - Storage backend
|
||||
/// * `dir` - Directory to scan
|
||||
/// * `ignore_patterns` - Patterns to exclude
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// Scan status with counts and any errors
|
||||
pub async fn scan_directory(
|
||||
storage: &DynStorageBackend,
|
||||
dir: &Path,
|
||||
|
|
@ -115,7 +127,19 @@ pub async fn scan_directory(
|
|||
.await
|
||||
}
|
||||
|
||||
/// Scan a directory with incremental scanning support
|
||||
/// Scans a directory with incremental scanning support.
|
||||
///
|
||||
/// Skips files that haven't changed since last scan based on mtime.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `storage` - Storage backend
|
||||
/// * `dir` - Directory to scan
|
||||
/// * `ignore_patterns` - Patterns to exclude
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// Scan status with counts and any errors
|
||||
pub async fn scan_directory_incremental(
|
||||
storage: &DynStorageBackend,
|
||||
dir: &Path,
|
||||
|
|
@ -129,6 +153,18 @@ pub async fn scan_directory_incremental(
|
|||
.await
|
||||
}
|
||||
|
||||
/// Scans a directory with progress reporting.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `storage` - Storage backend
|
||||
/// * `dir` - Directory to scan
|
||||
/// * `ignore_patterns` - Patterns to exclude
|
||||
/// * `progress` - Optional progress tracker
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// Scan status with counts and any errors
|
||||
pub async fn scan_directory_with_progress(
|
||||
storage: &DynStorageBackend,
|
||||
dir: &Path,
|
||||
|
|
@ -230,6 +266,16 @@ pub async fn scan_directory_with_options(
|
|||
Ok(status)
|
||||
}
|
||||
|
||||
/// Scans all configured root directories with default options.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `storage` - Storage backend
|
||||
/// * `ignore_patterns` - Patterns to exclude
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// Status for each root directory
|
||||
pub async fn scan_all_roots(
|
||||
storage: &DynStorageBackend,
|
||||
ignore_patterns: &[String],
|
||||
|
|
@ -243,7 +289,16 @@ pub async fn scan_all_roots(
|
|||
.await
|
||||
}
|
||||
|
||||
/// Scan all roots incrementally (skip unchanged files)
|
||||
/// Scans all roots incrementally, skipping unchanged files.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `storage` - Storage backend
|
||||
/// * `ignore_patterns` - Patterns to exclude
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// Status for each root directory
|
||||
pub async fn scan_all_roots_incremental(
|
||||
storage: &DynStorageBackend,
|
||||
ignore_patterns: &[String],
|
||||
|
|
@ -255,6 +310,17 @@ pub async fn scan_all_roots_incremental(
|
|||
scan_all_roots_with_options(storage, ignore_patterns, None, &options).await
|
||||
}
|
||||
|
||||
/// Scans all root directories with progress reporting.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `storage` - Storage backend
|
||||
/// * `ignore_patterns` - Patterns to exclude
|
||||
/// * `progress` - Optional progress tracker
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// Status for each root directory
|
||||
pub async fn scan_all_roots_with_progress(
|
||||
storage: &DynStorageBackend,
|
||||
ignore_patterns: &[String],
|
||||
|
|
@ -269,7 +335,18 @@ pub async fn scan_all_roots_with_progress(
|
|||
.await
|
||||
}
|
||||
|
||||
/// Scan all roots with full options including progress and incremental mode
|
||||
/// Scans all roots with full options including progress and incremental mode.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `storage` - Storage backend
|
||||
/// * `ignore_patterns` - Patterns to exclude
|
||||
/// * `progress` - Optional progress tracker
|
||||
/// * `scan_options` - Scan configuration
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// Status for each root directory
|
||||
pub async fn scan_all_roots_with_options(
|
||||
storage: &DynStorageBackend,
|
||||
ignore_patterns: &[String],
|
||||
|
|
@ -306,12 +383,14 @@ pub async fn scan_all_roots_with_options(
|
|||
Ok(statuses)
|
||||
}
|
||||
|
||||
/// Watches directories for file changes and imports modified files.
|
||||
pub struct FileWatcher {
|
||||
_watcher: Box<dyn Watcher + Send>,
|
||||
rx: mpsc::Receiver<PathBuf>,
|
||||
}
|
||||
|
||||
impl FileWatcher {
|
||||
/// Creates a new file watcher for the given directories.
|
||||
pub fn new(dirs: &[PathBuf]) -> Result<Self> {
|
||||
let (tx, rx) = mpsc::channel(1024);
|
||||
|
||||
|
|
@ -393,11 +472,13 @@ impl FileWatcher {
|
|||
Ok(Box::new(watcher))
|
||||
}
|
||||
|
||||
/// Receives the next changed file path.
|
||||
pub async fn next_change(&mut self) -> Option<PathBuf> {
|
||||
self.rx.recv().await
|
||||
}
|
||||
}
|
||||
|
||||
/// Watches directories and imports files on change.
|
||||
pub async fn watch_and_import(
|
||||
storage: DynStorageBackend,
|
||||
dirs: Vec<PathBuf>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue