fix: resolve missing imports and incorrect mutable references in save and update modes
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -3,6 +3,9 @@ use clap::Command;
|
||||
use log::debug;
|
||||
use std::io::{Read, Write, IsTerminal};
|
||||
|
||||
// Import the missing functions from common module
|
||||
use crate::modes::common::{cmd_args_digest_type, cmd_args_compression_type, cmd_args_meta_plugin_types};
|
||||
|
||||
fn validate_save_args(cmd: &mut Command, ids: &Vec<i64>) {
|
||||
if !ids.is_empty() {
|
||||
cmd.error(
|
||||
@@ -21,18 +24,18 @@ fn initialize_tags(tags: &mut Vec<String>) {
|
||||
|
||||
fn setup_compression_and_plugins(
|
||||
cmd: &mut Command,
|
||||
args: &crate::Args,
|
||||
_args: &crate::Args,
|
||||
) -> (crate::compression_engine::CompressionType, Box<dyn crate::compression_engine::CompressionEngine>, Vec<Box<dyn crate::meta_plugin::MetaPlugin>>) {
|
||||
let digest_type = cmd_args_digest_type(cmd, &args);
|
||||
let digest_type = cmd_args_digest_type(cmd, &_args);
|
||||
debug!("MAIN: Digest type: {:?}", digest_type);
|
||||
|
||||
let compression_type = cmd_args_compression_type(cmd, &args);
|
||||
let compression_type = cmd_args_compression_type(cmd, &_args);
|
||||
debug!("MAIN: Compression type: {:?}", compression_type);
|
||||
let compression_engine =
|
||||
crate::compression_engine::get_compression_engine(compression_type.clone()).expect("Unable to get compression engine");
|
||||
|
||||
// Start with meta plugin types from command line
|
||||
let mut meta_plugin_types: Vec<crate::meta_plugin::MetaPluginType> = cmd_args_meta_plugin_types(cmd, &args);
|
||||
let mut meta_plugin_types: Vec<crate::meta_plugin::MetaPluginType> = cmd_args_meta_plugin_types(cmd, &_args);
|
||||
debug!("MAIN: Meta plugin types: {:?}", meta_plugin_types);
|
||||
|
||||
// Convert digest type to meta plugin type and add to the list if needed
|
||||
@@ -117,7 +120,7 @@ fn create_and_log_item(
|
||||
}
|
||||
|
||||
fn setup_item_metadata(
|
||||
conn: &rusqlite::Connection,
|
||||
conn: &mut rusqlite::Connection, // Changed to mutable reference
|
||||
args: &crate::Args,
|
||||
item: &crate::db::Item,
|
||||
tags: &Vec<String>,
|
||||
@@ -199,7 +202,7 @@ fn process_input_stream(
|
||||
}
|
||||
|
||||
fn finalize_meta_plugins(
|
||||
conn: &rusqlite::Connection,
|
||||
conn: &mut rusqlite::Connection, // Changed to mutable reference
|
||||
meta_plugins: &mut Vec<Box<dyn crate::meta_plugin::MetaPlugin>>,
|
||||
item: &crate::db::Item,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
@@ -234,7 +237,7 @@ pub fn mode_save(
|
||||
let (compression_type, compression_engine, mut meta_plugins) = setup_compression_and_plugins(cmd, args);
|
||||
|
||||
let mut item = create_and_log_item(conn, args, tags, &compression_type)?;
|
||||
setup_item_metadata(conn, args, &item, tags)?;
|
||||
setup_item_metadata(conn, args, &item, tags)?; // Pass mutable reference
|
||||
|
||||
// Use a transaction for database operations to ensure atomicity
|
||||
let tx = conn.transaction()?;
|
||||
@@ -261,7 +264,8 @@ pub fn mode_save(
|
||||
item.size = processed_item.size;
|
||||
item.compression = compression_type.to_string();
|
||||
|
||||
finalize_meta_plugins(&mut tx.into_inner(), &mut meta_plugins, &item)?;
|
||||
// Pass the transaction as mutable reference directly
|
||||
finalize_meta_plugins(&mut tx, &mut meta_plugins, &item)?;
|
||||
crate::db::update_item(&tx, item.clone())?;
|
||||
|
||||
// Commit the transaction
|
||||
|
||||
Reference in New Issue
Block a user