Fix bugs across all crates

This commit is contained in:
2026-03-07 23:35:32 +02:00
parent 72c519bebc
commit 96f6973d39
8 changed files with 77 additions and 30 deletions

View File

@@ -573,25 +573,27 @@ fn cmd_undo(count: usize) {
entry.total, entry.input_dir
);
let mut batch_trashed = 0;
let mut remaining_files = Vec::new();
for file_path in &entry.output_files {
let path = PathBuf::from(file_path);
if path.exists() {
match trash::delete(&path) {
Ok(()) => {
batch_trashed += 1;
total_trashed += 1;
}
Err(e) => {
eprintln!(" Failed to trash {}: {}", path.display(), e);
remaining_files.push(file_path.clone());
}
}
}
}
// Keep entry in history if no files were trashed
if batch_trashed == 0 {
failed_entries.push(entry);
// Keep entry with remaining files if some could not be trashed
if !remaining_files.is_empty() {
let mut kept = entry;
kept.output_files = remaining_files;
failed_entries.push(kept);
}
}
@@ -665,7 +667,7 @@ fn cmd_watch_add(path: &str, preset_name: &str, recursive: bool) {
}
match serde_json::to_string_pretty(&watches) {
Ok(json) => {
if let Err(e) = std::fs::write(&watches_path, json) {
if let Err(e) = pixstrip_core::storage::atomic_write(&watches_path, &json) {
eprintln!("Failed to write watch config: {}", e);
std::process::exit(1);
}
@@ -743,7 +745,7 @@ fn cmd_watch_remove(path: &str) {
match serde_json::to_string_pretty(&watches) {
Ok(json) => {
if let Err(e) = std::fs::write(&watches_path, json) {
if let Err(e) = pixstrip_core::storage::atomic_write(&watches_path, &json) {
eprintln!("Failed to write watch config: {}", e);
std::process::exit(1);
}