-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
822 additions
and
463 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,49 @@ | ||
use crate::{ | ||
modules::selector::selector, | ||
utils::tools::{clear, pause}, | ||
utils::{ | ||
root_checker::root_checker, | ||
tools::{clear, pause}, | ||
}, | ||
}; | ||
use anyhow::Result; | ||
use cmd_lib::run_cmd; | ||
use color_print::{cformat, cprintln}; | ||
use dialoguer::{theme::ColorfulTheme, Confirm}; | ||
|
||
fn clean_cache() -> Result<()> { | ||
root_checker()?; | ||
|
||
if run_cmd!( | ||
sudo -E restic cache --cleanup | ||
) | ||
.is_err() | ||
{ | ||
cprintln!("\n<r>Failed to clean cache\n"); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn cache(noconfirm: bool) -> Result<()> { | ||
clear()?; | ||
cprintln!("<c,u,s>CACHE"); | ||
println!(); | ||
|
||
if noconfirm | ||
|| Confirm::with_theme(&ColorfulTheme::default()) | ||
.with_prompt(cformat!("<y>Do you want to clean cache? (Y/n): ")) | ||
.default(true) | ||
.interact()? | ||
{ | ||
if run_cmd!( | ||
restic cache --cleanup | ||
) | ||
.is_err() | ||
{ | ||
cprintln!("<r>Failed to clean cache"); | ||
} | ||
clean_cache()?; | ||
|
||
if !noconfirm { | ||
pause()?; | ||
selector()?; | ||
} | ||
} else { | ||
selector()?; | ||
} | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.