pinakes-core: improve media management features; various configuration improvements
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I2d1f04f13970d21c36067f30bc04a9176a6a6964
This commit is contained in:
parent
cfdc3d0622
commit
e02c15490e
31 changed files with 1167 additions and 197 deletions
|
|
@ -21,12 +21,24 @@ pub struct ImportResult {
|
|||
}
|
||||
|
||||
/// Options for import operations
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ImportOptions {
|
||||
/// Skip files that haven't changed since last scan (based on mtime)
|
||||
pub incremental: bool,
|
||||
/// Force re-import even if mtime hasn't changed
|
||||
pub force: bool,
|
||||
/// Photo configuration for toggleable features
|
||||
pub photo_config: crate::config::PhotoConfig,
|
||||
}
|
||||
|
||||
impl Default for ImportOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
incremental: false,
|
||||
force: false,
|
||||
photo_config: crate::config::PhotoConfig::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the modification time of a file as a Unix timestamp
|
||||
|
|
@ -147,6 +159,15 @@ pub async fn import_file_with_options(
|
|||
.map_err(|e| PinakesError::MetadataExtraction(e.to_string()))??
|
||||
};
|
||||
|
||||
// Generate perceptual hash for image files (if enabled in config)
|
||||
let perceptual_hash = if options.photo_config.generate_perceptual_hash
|
||||
&& media_type.category() == crate::media_type::MediaCategory::Image
|
||||
{
|
||||
crate::metadata::image::generate_perceptual_hash(&path)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let item = MediaItem {
|
||||
id: media_id,
|
||||
path: path.clone(),
|
||||
|
|
@ -164,6 +185,16 @@ pub async fn import_file_with_options(
|
|||
thumbnail_path: thumb_path,
|
||||
custom_fields: std::collections::HashMap::new(),
|
||||
file_mtime: current_mtime,
|
||||
|
||||
// Photo-specific metadata from extraction
|
||||
date_taken: extracted.date_taken,
|
||||
latitude: extracted.latitude,
|
||||
longitude: extracted.longitude,
|
||||
camera_make: extracted.camera_make,
|
||||
camera_model: extracted.camera_model,
|
||||
rating: extracted.rating,
|
||||
perceptual_hash,
|
||||
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue