mirror of
https://github.com/sreedevk/deduplicator.git
synced 2026-09-07 10:34:22 +00:00
added delete options
This commit is contained in:
@@ -1,7 +1,14 @@
|
|||||||
use crate::database::File;
|
use crate::database::File;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use colored::Colorize;
|
||||||
|
|
||||||
pub fn delete_files(files: Vec<File>) -> Result<()> {
|
pub fn delete_files(files: Vec<File>) -> Result<()> {
|
||||||
println!("{:?} DELETED", files);
|
files.into_iter().for_each(|file| {
|
||||||
|
match std::fs::remove_file(file.path.clone()) {
|
||||||
|
Ok(_) => println!("{}: {}", "DELETED".green(), file.path),
|
||||||
|
Err(e) => println!("{}: {}", "FAILED".red(), file.path)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,12 +97,14 @@ fn process_group_action(duplicates: &Vec<File>, dup_index: usize, dup_size: usiz
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.any(|index| index > (duplicates.len() - 1))
|
.any(|index| index > (duplicates.len() - 1))
|
||||||
{
|
{
|
||||||
println!("Err: File Index Out of Bounds!");
|
println!("{}", "Err: File Index Out of Bounds!".red());
|
||||||
return process_group_action(duplicates, dup_index, dup_size, table);
|
return process_group_action(duplicates, dup_index, dup_size, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
|
print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
|
||||||
|
|
||||||
|
if parsed_file_indices.is_empty() { return }
|
||||||
|
|
||||||
let files_to_delete = parsed_file_indices
|
let files_to_delete = parsed_file_indices
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|index| duplicates[index].clone());
|
.map(|index| duplicates[index].clone());
|
||||||
|
|||||||
Reference in New Issue
Block a user