refactor: reimplement digest engines as meta plugins
Co-authored-by: aider (openai/andrew.openrouter.qwen.qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -12,9 +12,8 @@ use std::path::PathBuf;
|
||||
|
||||
use crate::compression_engine::get_compression_engine;
|
||||
use crate::db::{self};
|
||||
use crate::digest_engine::get_digest_engine;
|
||||
use crate::meta_plugin::{MetaPlugin, MetaPluginType, get_meta_plugin};
|
||||
use crate::modes::common::{cmd_args_compression_type, cmd_args_digest_type, cmd_args_meta_plugin_types, store_item_digest_value, get_meta_from_env, store_item_meta_value};
|
||||
use crate::modes::common::{cmd_args_compression_type, cmd_args_digest_type, cmd_args_meta_plugin_types, get_meta_from_env, store_item_meta_value};
|
||||
use chrono::Utc;
|
||||
|
||||
pub fn mode_save(
|
||||
@@ -39,7 +38,18 @@ pub fn mode_save(
|
||||
|
||||
let digest_type = cmd_args_digest_type(cmd, &args);
|
||||
debug!("MAIN: Digest type: {:?}", digest_type);
|
||||
let mut digest_engine = get_digest_engine(digest_type.clone());
|
||||
|
||||
// Convert digest type to meta plugin type
|
||||
let digest_meta_plugin_type = match digest_type {
|
||||
crate::digest_engine::DigestType::Sha256 => Some(MetaPluginType::DigestSha256),
|
||||
crate::digest_engine::DigestType::Md5 => Some(MetaPluginType::DigestMd5),
|
||||
crate::digest_engine::DigestType::None => None,
|
||||
};
|
||||
|
||||
// Add digest meta plugin to the list if needed
|
||||
if let Some(digest_plugin_type) = digest_meta_plugin_type {
|
||||
meta_plugin_types.push(digest_plugin_type);
|
||||
}
|
||||
|
||||
let compression_type = cmd_args_compression_type(cmd, &args);
|
||||
debug!("MAIN: Compression type: {:?}", compression_type);
|
||||
@@ -146,7 +156,6 @@ pub fn mode_save(
|
||||
|
||||
stdout.write_all(&buffer[..n])?;
|
||||
item_out.write_all(&buffer[..n])?;
|
||||
digest_engine.update(&buffer[..n]);
|
||||
|
||||
for meta_plugin in meta_plugins.iter_mut() {
|
||||
meta_plugin.update(&buffer[..n]);
|
||||
@@ -157,11 +166,6 @@ pub fn mode_save(
|
||||
stdout.flush()?;
|
||||
item_out.flush()?;
|
||||
|
||||
let digest = digest_engine.finalize()?;
|
||||
debug!("DIGEST: {}", digest);
|
||||
|
||||
store_item_digest_value(conn, item.clone(), digest_type, digest)?;
|
||||
|
||||
for meta_plugin in meta_plugins.iter_mut() {
|
||||
let meta_name = meta_plugin.meta_name();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user