aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
28
akode-rs/windows-sandbox-service/src/uninstall_policy.rs
Normal file
28
akode-rs/windows-sandbox-service/src/uninstall_policy.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
//! Reads the owner's current home-deletion preference; existing OEM preinstalls retain their default.
|
||||
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
|
||||
use akode_config::AbsolutePathBufGuard;
|
||||
use akode_config::config_toml::ConfigToml;
|
||||
|
||||
pub(crate) fn clean_uninstall_enabled(home: &Path, preinstalled: bool) -> bool {
|
||||
let contents = match std::fs::read_to_string(home.join("config.toml")) {
|
||||
Ok(contents) => contents,
|
||||
Err(error) if error.kind() == io::ErrorKind::NotFound => return preinstalled,
|
||||
Err(_) => return false,
|
||||
};
|
||||
let _guard = AbsolutePathBufGuard::new(home);
|
||||
let Ok(config) = toml::from_str::<ConfigToml>(&contents) else {
|
||||
return false;
|
||||
};
|
||||
config
|
||||
.desktop
|
||||
.as_ref()
|
||||
.and_then(|desktop| desktop.get("uninstall_codex_home"))
|
||||
.map_or(preinstalled, |value| value.as_bool().unwrap_or(false))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "uninstall_policy_tests.rs"]
|
||||
mod tests;
|
||||
Reference in New Issue
Block a user