ksud: fmt

This commit is contained in:
ShirkNeko
2025-06-27 11:15:19 +08:00
parent 4532bab230
commit 634adad15c
6 changed files with 39 additions and 40 deletions

View File

@@ -1,9 +1,9 @@
use anyhow::Result;
use notify::{Watcher, RecursiveMode};
use std::path::Path;
use std::fs;
use anyhow::anyhow;
use notify::{RecursiveMode, Watcher};
use std::ffi::OsStr;
use std::fs;
use std::path::Path;
pub const KPM_DIR: &str = "/data/adb/kpm";
pub const KPMMGR_PATH: &str = "/data/adb/ksu/bin/kpmmgr";
@@ -28,11 +28,9 @@ pub fn start_kpm_watcher() -> Result<()> {
return Ok(());
}
let mut watcher = notify::recommended_watcher(|res| {
match res {
Ok(event) => handle_kpm_event(event),
Err(e) => log::error!("monitoring error: {:?}", e),
}
let mut watcher = notify::recommended_watcher(|res| match res {
Ok(event) => handle_kpm_event(event),
Err(e) => log::error!("monitoring error: {:?}", e),
})?;
watcher.watch(Path::new(KPM_DIR), RecursiveMode::NonRecursive)?;
@@ -80,7 +78,9 @@ fn handle_modify_event(paths: Vec<std::path::PathBuf>) {
// 加载 KPM 模块
pub fn load_kpm(path: &Path) -> Result<()> {
let path_str = path.to_str().ok_or_else(|| anyhow!("Invalid path: {}", path.display()))?;
let path_str = path
.to_str()
.ok_or_else(|| anyhow!("Invalid path: {}", path.display()))?;
let status = std::process::Command::new(KPMMGR_PATH)
.args(["load", path_str, ""])
.status()?;
@@ -168,7 +168,6 @@ pub fn load_kpm_modules() -> Result<()> {
}
}
}
if path.extension().is_some_and(|ext| ext == "kpm") {
match load_kpm(&path) {
Ok(()) => log::info!("Successfully loaded KPM module: {}", path.display()),
@@ -178,4 +177,4 @@ pub fn load_kpm_modules() -> Result<()> {
}
Ok(())
}
}