Skip to content
Snippets Groups Projects
Verified Commit 8166c524 authored by nfontrod's avatar nfontrod
Browse files

src/clean.rs: add clean module

parent b7da81e2
No related branches found
No related tags found
No related merge requests found
use crate::commit;
use colored::Colorize;
use std::{path::PathBuf, process::exit};
/// Get the path of the .tmp folder
///
/// # Description
/// Get the path of the .tmp folder at the root of the project folder but don't
/// create it
pub(crate) fn get_tmp_path(borgfolder: &PathBuf) -> PathBuf {
let mut tmp_folder = borgfolder.parent().unwrap().to_path_buf();
tmp_folder.push(".tmp");
tmp_folder
}
/// Function used to remove the .tmp repository
pub fn clean() {
let (borg_folder, _) = commit::check_path();
let tmp_folder = get_tmp_path(&borg_folder);
if !tmp_folder.is_dir() {
println!("{}: The .tmp folder doesn't exits !", "info".blue());
return ();
}
match std::fs::remove_dir_all(&tmp_folder) {
Ok(_) => (),
Err(e) => {
eprintln!("{}: Unable to remove .tmp directory. {}", "error".red(), e);
exit(1);
}
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment