pub struct MediaScanner { /* private fields */ }Expand description
Media scanner that uses the file system manager and database for efficient scanning
Implementations§
Source§impl MediaScanner
impl MediaScanner
Sourcepub async fn new() -> Result<Self>
pub async fn new() -> Result<Self>
Create a new media scanner with platform-specific file system manager
Sourcepub fn with_database(database_manager: Arc<dyn DatabaseManager>) -> Self
pub fn with_database(database_manager: Arc<dyn DatabaseManager>) -> Self
Create a new media scanner with database manager
Sourcepub async fn scan_directory_simple(
&self,
directory: &Path,
) -> Result<Vec<MediaFile>>
pub async fn scan_directory_simple( &self, directory: &Path, ) -> Result<Vec<MediaFile>>
Simple directory scan that returns files without database operations
Sourcepub async fn scan_directory_recursively_simple(
&self,
directory: &Path,
) -> Result<Vec<MediaFile>>
pub async fn scan_directory_recursively_simple( &self, directory: &Path, ) -> Result<Vec<MediaFile>>
Simple recursive directory scan that returns files without database operations
Sourcepub fn with_filesystem_manager(
filesystem_manager: Box<dyn FileSystemManager>,
database_manager: Arc<dyn DatabaseManager>,
) -> Self
pub fn with_filesystem_manager( filesystem_manager: Box<dyn FileSystemManager>, database_manager: Arc<dyn DatabaseManager>, ) -> Self
Create a media scanner with a custom file system manager (for testing)
Sourcepub async fn scan_directory(&self, directory: &Path) -> Result<ScanResult>
pub async fn scan_directory(&self, directory: &Path) -> Result<ScanResult>
Perform a full scan of a directory, updating the database with new/changed files
Sourcepub async fn scan_directories(
&self,
directories: &[PathBuf],
) -> Result<ScanResult>
pub async fn scan_directories( &self, directories: &[PathBuf], ) -> Result<ScanResult>
Scan multiple directories and return combined results
Sourcepub async fn scan_directory_recursive(
&self,
directory: &Path,
) -> Result<ScanResult>
pub async fn scan_directory_recursive( &self, directory: &Path, ) -> Result<ScanResult>
Perform a recursive scan of a directory and its subdirectories
This method is optimized to avoid N+1 query problems by loading all existing files from the database once at the start, then passing this collection down to each directory scan. This significantly improves performance for large directory structures.
The method also implements batch processing to handle very large directory structures efficiently without blocking the async runtime.
Sourcepub fn filesystem_manager(&self) -> &dyn FileSystemManager
pub fn filesystem_manager(&self) -> &dyn FileSystemManager
Get the file system manager (for testing or advanced usage)