refactor: decouple meta plugins from DB via SaveMetaFn callback, extract shared utilities
- Add SaveMetaFn callback pattern: meta plugins receive a closure instead of
&Connection, enabling the same plugin code to work in local, client, and
server contexts (collect-to-Vec, collect-to-HashMap, or direct DB write)
- Client save now runs meta plugins locally during streaming (smart client
sets meta=false, server skips its own plugins)
- Add POST /api/item/{id}/update endpoint for re-running plugins on stored
content without downloading compressed data
- Add client update mode (--update with --meta-plugin flags)
- Extract shared utilities: stream_copy, print_serialized, build_path_table,
ensure_default_tag to reduce duplication across modes
- Add upsert_tag for idempotent tag addition (INSERT OR IGNORE)
- Add warn logging on save_meta lock failure in BaseMetaPlugin and MetaService
This commit is contained in:
@@ -123,6 +123,14 @@ impl MetaPlugin for MagicFileMetaPluginImpl {
|
||||
self.is_finalized = finalized;
|
||||
}
|
||||
|
||||
fn set_save_meta(&mut self, save_meta: crate::meta_plugin::SaveMetaFn) {
|
||||
self.base.set_save_meta(save_meta);
|
||||
}
|
||||
|
||||
fn save_meta(&self, name: &str, value: &str) {
|
||||
self.base.save_meta(name, value);
|
||||
}
|
||||
|
||||
fn initialize(&mut self) -> MetaPluginResponse {
|
||||
// Cookie is lazily initialized in the thread-local on first use.
|
||||
MetaPluginResponse {
|
||||
@@ -335,6 +343,14 @@ impl MetaPlugin for FallbackMagicFileMetaPlugin {
|
||||
self.is_finalized = finalized;
|
||||
}
|
||||
|
||||
fn set_save_meta(&mut self, save_meta: crate::meta_plugin::SaveMetaFn) {
|
||||
self.base.set_save_meta(save_meta);
|
||||
}
|
||||
|
||||
fn save_meta(&self, name: &str, value: &str) {
|
||||
self.base.save_meta(name, value);
|
||||
}
|
||||
|
||||
fn initialize(&mut self) -> MetaPluginResponse {
|
||||
MetaPluginResponse {
|
||||
metadata: Vec::new(),
|
||||
|
||||
Reference in New Issue
Block a user