mirror of
https://github.com/forkless/NotAlterra.git
synced 2026-08-16 00:26:38 +02:00
reject_disclaimer: delete sentinel file on decline
Added reject_disclaimer() to config.rs that removes the NOTALTERRA_LICENSE_ACCEPTED sentinel if it exists. Called from both decline paths in run_disclaimer() — the N/n key shortcut and Enter with No selected.
This commit is contained in:
@@ -50,6 +50,15 @@ pub fn accept_disclaimer() -> std::io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Remove the disclaimer sentinel if it exists.
|
||||
pub fn reject_disclaimer() -> std::io::Result<()> {
|
||||
let p = sentinel_path();
|
||||
if p.exists() {
|
||||
std::fs::remove_file(p)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Path to the stale `config.ini` from v0.3.0 and earlier.
|
||||
pub fn stale_config_path() -> PathBuf {
|
||||
exe_dir().join("config.ini")
|
||||
|
||||
@@ -349,6 +349,7 @@ fn run_disclaimer<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -> Resu
|
||||
}
|
||||
KeyCode::Char('n') | KeyCode::Char('N') => {
|
||||
guard::log_action("LICENSE", "declined", "OK", &app.log_path)?;
|
||||
crate::config::reject_disclaimer()?;
|
||||
return Ok(Some(false));
|
||||
}
|
||||
KeyCode::Esc => {
|
||||
@@ -360,6 +361,8 @@ fn run_disclaimer<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) -> Resu
|
||||
guard::log_action("LICENSE", detail, "OK", &app.log_path)?;
|
||||
if accepted {
|
||||
crate::config::accept_disclaimer()?;
|
||||
} else {
|
||||
crate::config::reject_disclaimer()?;
|
||||
}
|
||||
return Ok(Some(accepted));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user