refactor: unify digest plugin type handling
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use sha2::{Digest, Sha256, Sha512};
|
||||
use md5::Md5;
|
||||
use crate::meta_plugin::MetaPlugin;
|
||||
use crate::meta_plugin::{MetaPlugin, process_metadata_outputs};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum Hasher {
|
||||
|
||||
@@ -16,7 +16,7 @@ pub mod shell_pid;
|
||||
pub mod keep_pid;
|
||||
|
||||
use crate::meta_plugin::program::MetaPluginProgram;
|
||||
use crate::meta_plugin::digest::DigestSha256MetaPlugin;
|
||||
use crate::meta_plugin::digest::DigestMetaPlugin;
|
||||
use crate::meta_plugin::read_time::ReadTimeMetaPlugin;
|
||||
use crate::meta_plugin::read_rate::ReadRateMetaPlugin;
|
||||
use crate::meta_plugin::magic::MagicFileMetaPlugin;
|
||||
|
||||
@@ -169,22 +169,9 @@ pub fn settings_meta_plugin_types(cmd: &mut Command, settings: &config::Settings
|
||||
meta_plugin_types
|
||||
}
|
||||
|
||||
pub fn settings_digest_type(cmd: &mut Command, settings: &config::Settings) -> MetaPluginType {
|
||||
let digest_name = settings
|
||||
.digest
|
||||
.clone()
|
||||
.unwrap_or(MetaPluginType::DigestSha256.to_string());
|
||||
|
||||
let digest_type_opt = MetaPluginType::from_str(&digest_name);
|
||||
if digest_type_opt.is_err() {
|
||||
cmd.error(
|
||||
ErrorKind::InvalidValue,
|
||||
format!("Invalid digest algorithm '{}'. Use 'sha256' or 'md5'", digest_name),
|
||||
)
|
||||
.exit();
|
||||
}
|
||||
|
||||
digest_type_opt.unwrap()
|
||||
pub fn settings_digest_type(_cmd: &mut Command, _settings: &config::Settings) -> MetaPluginType {
|
||||
// The digest plugin is now unified, always return Digest
|
||||
MetaPluginType::Digest
|
||||
}
|
||||
|
||||
pub fn settings_compression_type(cmd: &mut Command, settings: &config::Settings) -> CompressionType {
|
||||
|
||||
@@ -141,18 +141,9 @@ pub fn mode_status(
|
||||
let mut meta_plugin_types: Vec<MetaPluginType> = crate::modes::common::settings_meta_plugin_types(_cmd, settings);
|
||||
log::debug!("STATUS: Got {} meta plugin types", meta_plugin_types.len());
|
||||
|
||||
// Add digest type if specified
|
||||
let digest_type = crate::modes::common::settings_digest_type(_cmd, settings);
|
||||
let digest_meta_plugin_type = match digest_type {
|
||||
crate::meta_plugin::MetaPluginType::DigestSha256 => Some(MetaPluginType::DigestSha256),
|
||||
crate::meta_plugin::MetaPluginType::DigestMd5 => Some(MetaPluginType::DigestMd5),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if let Some(digest_plugin_type) = digest_meta_plugin_type {
|
||||
if !meta_plugin_types.contains(&digest_plugin_type) {
|
||||
meta_plugin_types.push(digest_plugin_type);
|
||||
}
|
||||
// Always add the Digest plugin if not present
|
||||
if !meta_plugin_types.contains(&MetaPluginType::Digest) {
|
||||
meta_plugin_types.push(MetaPluginType::Digest);
|
||||
}
|
||||
|
||||
// Determine which compression type would be enabled for a save operation
|
||||
|
||||
@@ -18,19 +18,10 @@ impl MetaService {
|
||||
let mut meta_plugin_types: Vec<MetaPluginType> = settings_meta_plugin_types(cmd, settings);
|
||||
debug!("META_SERVICE: Meta plugin types from settings: {:?}", meta_plugin_types);
|
||||
|
||||
let digest_type = settings_digest_type(cmd, settings);
|
||||
debug!("META_SERVICE: Digest type: {:?}", digest_type);
|
||||
let digest_meta_plugin_type = match digest_type {
|
||||
MetaPluginType::DigestSha256 => Some(MetaPluginType::DigestSha256),
|
||||
MetaPluginType::DigestMd5 => Some(MetaPluginType::DigestMd5),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if let Some(digest_plugin_type) = digest_meta_plugin_type {
|
||||
if !meta_plugin_types.contains(&digest_plugin_type) {
|
||||
debug!("META_SERVICE: Adding digest plugin type: {:?}", digest_plugin_type);
|
||||
meta_plugin_types.push(digest_plugin_type);
|
||||
}
|
||||
// Always add the Digest plugin if not present
|
||||
if !meta_plugin_types.contains(&MetaPluginType::Digest) {
|
||||
debug!("META_SERVICE: Adding digest plugin type");
|
||||
meta_plugin_types.push(MetaPluginType::Digest);
|
||||
}
|
||||
|
||||
debug!("META_SERVICE: Meta plugin types: {:?}", meta_plugin_types);
|
||||
|
||||
Reference in New Issue
Block a user