feat: update digest and system plugins to return PluginResponse
Co-authored-by: aider (openai/andrew/openrouter/mistralai/mistral-medium-3.1) <aider@aider.chat>
This commit is contained in:
@@ -58,25 +58,34 @@ impl MetaPlugin for DigestSha256MetaPlugin {
|
||||
true
|
||||
}
|
||||
|
||||
fn initialize(&mut self, _conn: &Connection, item_id: i64) -> Result<()> {
|
||||
fn initialize(&mut self, item_id: i64) -> Result<PluginResponse> {
|
||||
self.item_id = Some(item_id);
|
||||
Ok(())
|
||||
Ok(PluginResponse::default())
|
||||
}
|
||||
|
||||
fn finalize(&mut self, conn: &Connection) -> Result<()> {
|
||||
fn finalize(&mut self) -> Result<PluginResponse> {
|
||||
let mut metadata = Vec::new();
|
||||
|
||||
if let Some(item_id) = self.item_id {
|
||||
// Finalize the hash
|
||||
let hash_result = self.hasher.finalize_reset();
|
||||
let hex_string = format!("{:x}", hash_result);
|
||||
|
||||
// Save the hash as metadata using central output handler
|
||||
let _ = self.save_meta(conn, item_id, "digest_sha256", hex_string);
|
||||
// Create metadata to be stored
|
||||
if let Some(meta) = self.create_meta(item_id, "digest_sha256", hex_string) {
|
||||
metadata.push(meta);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update(&mut self, data: &[u8], _conn: &Connection) {
|
||||
Ok(PluginResponse {
|
||||
metadata: Some(metadata),
|
||||
is_finalized: true,
|
||||
})
|
||||
}
|
||||
|
||||
fn update(&mut self, data: &[u8]) -> Result<PluginResponse> {
|
||||
self.hasher.update(data);
|
||||
Ok(PluginResponse::default())
|
||||
}
|
||||
|
||||
fn meta_name(&self) -> String {
|
||||
|
||||
@@ -174,11 +174,18 @@ impl MetaPlugin for UidMetaPlugin {
|
||||
self.meta_name.clone()
|
||||
}
|
||||
|
||||
fn initialize(&mut self, conn: &Connection, item_id: i64) -> Result<()> {
|
||||
fn initialize(&mut self, item_id: i64) -> Result<PluginResponse> {
|
||||
let mut metadata = Vec::new();
|
||||
let uid = get_current_uid().to_string();
|
||||
self.save_meta(conn, item_id, "uid", uid)?;
|
||||
self.is_saved = true;
|
||||
Ok(())
|
||||
|
||||
if let Some(meta) = self.create_meta(item_id, "uid", uid) {
|
||||
metadata.push(meta);
|
||||
}
|
||||
|
||||
Ok(PluginResponse {
|
||||
metadata: Some(metadata),
|
||||
is_finalized: true,
|
||||
})
|
||||
}
|
||||
|
||||
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
|
||||
|
||||
Reference in New Issue
Block a user