Skip to content

Commit

Permalink
ksud: remove modules dir when uninstall. close #1736
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed May 28, 2024
1 parent 916d6bc commit f381e32
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions userspace/ksud/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub fn has_magisk() -> bool {
}

fn is_ok_empty(dir: &str) -> bool {
use std::result::Result::{Err, Ok};
use std::result::Result::Ok;

match fs::read_dir(dir) {
Ok(mut entries) => entries.next().is_none(),
Expand All @@ -199,7 +199,7 @@ fn is_ok_empty(dir: &str) -> bool {
}

fn find_temp_path() -> String {
use std::result::Result::{Err, Ok};
use std::result::Result::Ok;

if is_ok_empty(defs::TEMP_DIR) {
return defs::TEMP_DIR.to_string();
Expand Down Expand Up @@ -286,8 +286,11 @@ pub fn uninstall(magiskboot_path: Option<PathBuf>) -> Result<()> {
module::prune_modules()?;
}
println!("- Removing directories..");
std::fs::remove_dir_all(defs::WORKING_DIR)?;
std::fs::remove_file(defs::DAEMON_PATH)?;
std::fs::remove_dir_all(defs::WORKING_DIR).ok();
std::fs::remove_file(defs::DAEMON_PATH).ok();
crate::mount::umount_dir(defs::MODULE_DIR).ok();
std::fs::remove_dir_all(defs::MODULE_DIR).ok();
std::fs::remove_dir_all(defs::MODULE_UPDATE_TMP_DIR).ok();
println!("- Restore boot image..");
boot_patch::restore(None, magiskboot_path, true)?;
println!("- Uninstall KernelSU manager..");
Expand Down

0 comments on commit f381e32

Please sign in to comment.