feat: add central metadata output handler
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -3,7 +3,7 @@ use magic::{Cookie, CookieFlags};
|
||||
use rusqlite::Connection;
|
||||
use std::io;
|
||||
|
||||
use crate::meta_plugin::MetaPlugin;
|
||||
use crate::meta_plugin::{MetaPlugin, output_metadata};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MagicFileMetaPlugin {
|
||||
@@ -64,36 +64,21 @@ impl MagicFileMetaPlugin {
|
||||
// Save file type
|
||||
if let Ok(file_type) = self.get_magic_result(CookieFlags::empty()) {
|
||||
if !file_type.is_empty() {
|
||||
let meta = crate::db::Meta {
|
||||
id: item_id,
|
||||
name: self.get_output_name("file_type"),
|
||||
value: file_type,
|
||||
};
|
||||
let _ = crate::db::store_meta(conn_ref, meta);
|
||||
let _ = output_metadata(conn_ref, item_id, "file_type", file_type, &self.output_names);
|
||||
}
|
||||
}
|
||||
|
||||
// Save MIME type
|
||||
if let Ok(mime_type) = self.get_magic_result(CookieFlags::MIME_TYPE) {
|
||||
if !mime_type.is_empty() {
|
||||
let meta = crate::db::Meta {
|
||||
id: item_id,
|
||||
name: self.get_output_name("mime_type"),
|
||||
value: mime_type,
|
||||
};
|
||||
let _ = crate::db::store_meta(conn_ref, meta);
|
||||
let _ = output_metadata(conn_ref, item_id, "mime_type", mime_type, &self.output_names);
|
||||
}
|
||||
}
|
||||
|
||||
// Save MIME encoding
|
||||
if let Ok(mime_encoding) = self.get_magic_result(CookieFlags::MIME_ENCODING) {
|
||||
if !mime_encoding.is_empty() {
|
||||
let meta = crate::db::Meta {
|
||||
id: item_id,
|
||||
name: self.get_output_name("mime_encoding"),
|
||||
value: mime_encoding,
|
||||
};
|
||||
let _ = crate::db::store_meta(conn_ref, meta);
|
||||
let _ = output_metadata(conn_ref, item_id, "mime_encoding", mime_encoding, &self.output_names);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user