feat: add combined mime info support and remove metadata filtering
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -60,32 +60,50 @@ impl MagicFileMetaPlugin {
|
||||
|
||||
// Save file type
|
||||
if let Ok(file_type) = self.get_magic_result(CookieFlags::empty()) {
|
||||
let meta = crate::db::Meta {
|
||||
id: item_id,
|
||||
name: "magic_file_type".to_string(),
|
||||
value: file_type,
|
||||
};
|
||||
let _ = crate::db::store_meta(conn_ref, meta);
|
||||
if !file_type.is_empty() {
|
||||
let meta = crate::db::Meta {
|
||||
id: item_id,
|
||||
name: "magic_file_type".to_string(),
|
||||
value: file_type,
|
||||
};
|
||||
let _ = crate::db::store_meta(conn_ref, meta);
|
||||
}
|
||||
}
|
||||
|
||||
// Save MIME type
|
||||
if let Ok(mime_type) = self.get_magic_result(CookieFlags::MIME_TYPE) {
|
||||
let meta = crate::db::Meta {
|
||||
id: item_id,
|
||||
name: "magic_mime_type".to_string(),
|
||||
value: mime_type,
|
||||
};
|
||||
let _ = crate::db::store_meta(conn_ref, meta);
|
||||
if !mime_type.is_empty() {
|
||||
let meta = crate::db::Meta {
|
||||
id: item_id,
|
||||
name: "magic_mime_type".to_string(),
|
||||
value: mime_type,
|
||||
};
|
||||
let _ = crate::db::store_meta(conn_ref, meta);
|
||||
}
|
||||
}
|
||||
|
||||
// Save MIME encoding
|
||||
if let Ok(mime_encoding) = self.get_magic_result(CookieFlags::MIME_ENCODING) {
|
||||
let meta = crate::db::Meta {
|
||||
id: item_id,
|
||||
name: "magic_mime_encoding".to_string(),
|
||||
value: mime_encoding,
|
||||
};
|
||||
let _ = crate::db::store_meta(conn_ref, meta);
|
||||
if !mime_encoding.is_empty() {
|
||||
let meta = crate::db::Meta {
|
||||
id: item_id,
|
||||
name: "magic_mime_encoding".to_string(),
|
||||
value: mime_encoding,
|
||||
};
|
||||
let _ = crate::db::store_meta(conn_ref, meta);
|
||||
}
|
||||
}
|
||||
|
||||
// Save combined MIME info (type and encoding together)
|
||||
if let Ok(mime_combined) = self.get_magic_result(CookieFlags::MIME) {
|
||||
if !mime_combined.is_empty() {
|
||||
let meta = crate::db::Meta {
|
||||
id: item_id,
|
||||
name: "magic_mime_combined".to_string(),
|
||||
value: mime_combined,
|
||||
};
|
||||
let _ = crate::db::store_meta(conn_ref, meta);
|
||||
}
|
||||
}
|
||||
|
||||
self.is_saved = true;
|
||||
@@ -105,7 +123,7 @@ impl MetaPlugin for MagicFileMetaPlugin {
|
||||
self.conn = Some(conn as *const _ as *mut Connection);
|
||||
|
||||
// Initialize magic cookie with flags for comprehensive detection
|
||||
let cookie = Cookie::open(CookieFlags::MIME_TYPE | CookieFlags::MIME_ENCODING)
|
||||
let cookie = Cookie::open(CookieFlags::MIME_TYPE | CookieFlags::MIME_ENCODING | CookieFlags::MIME)
|
||||
.map_err(|e| anyhow::anyhow!("Failed to open magic cookie: {}", e))?;
|
||||
cookie.load(&[] as &[&str])
|
||||
.map_err(|e| anyhow::anyhow!("Failed to load magic database: {}", e))?;
|
||||
|
||||
Reference in New Issue
Block a user