refactor: Remove transaction from save to allow partial saves on failure
Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
@@ -244,9 +244,8 @@ pub fn mode_save(
|
||||
let mut item = create_and_log_item(conn, args, tags, &compression_type)?;
|
||||
setup_item_metadata(conn, args, &item, tags)?; // Pass mutable reference
|
||||
|
||||
// Use a transaction for database operations to ensure atomicity
|
||||
let tx = conn.transaction()?;
|
||||
|
||||
// Save as much as possible in case something breaks - don't use transactions
|
||||
// This allows partial saves to succeed even if some metadata operations fail
|
||||
let item_meta = collect_item_meta(args);
|
||||
let item_id = item.id.ok_or_else(|| anyhow!("Item missing ID"))?;
|
||||
|
||||
@@ -256,7 +255,7 @@ pub fn mode_save(
|
||||
name: kv.0.to_string(),
|
||||
value: kv.1.to_string(),
|
||||
};
|
||||
crate::db::store_meta(&tx, meta)?;
|
||||
crate::db::store_meta(conn, meta)?;
|
||||
}
|
||||
|
||||
let (_item_out, processed_item) = process_input_stream(
|
||||
@@ -269,11 +268,8 @@ pub fn mode_save(
|
||||
item.size = processed_item.size;
|
||||
item.compression = compression_type.to_string();
|
||||
|
||||
finalize_meta_plugins(&tx, &mut meta_plugins, &item)?;
|
||||
crate::db::update_item(&tx, item.clone())?;
|
||||
|
||||
// Commit the transaction
|
||||
tx.commit()?;
|
||||
finalize_meta_plugins(conn, &mut meta_plugins, &item)?;
|
||||
crate::db::update_item(conn, item.clone())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user