ksud: Fix clippy

This commit is contained in:
weishu
2024-04-12 10:36:25 +08:00
parent 705a9b7238
commit 6ea2438425
2 changed files with 4 additions and 6 deletions

View File

@@ -148,12 +148,10 @@ fn dd<P: AsRef<Path>, Q: AsRef<Path>>(ifile: P, ofile: Q) -> Result<()> {
} }
pub fn restore( pub fn restore(
image: impl AsRef<Path>, image: Option<PathBuf>,
magiskboot_path: Option<PathBuf>, magiskboot_path: Option<PathBuf>,
flash: bool, flash: bool,
) -> Result<()> { ) -> Result<()> {
let image = image.as_ref();
ensure!(image.exists(), "boot image not found");
let workding_dir = let workding_dir =
tempdir::TempDir::new("KernelSU").with_context(|| "create temp dir failed")?; tempdir::TempDir::new("KernelSU").with_context(|| "create temp dir failed")?;
let magiskboot = find_magiskboot(magiskboot_path, workding_dir.path())?; let magiskboot = find_magiskboot(magiskboot_path, workding_dir.path())?;
@@ -196,7 +194,7 @@ pub fn restore(
ensure!(status.success(), "magiskboot repack failed"); ensure!(status.success(), "magiskboot repack failed");
let new_boot = workding_dir.path().join("new-boot.img"); let new_boot = workding_dir.path().join("new-boot.img");
if image.exists() { if image.is_some() {
// if image is specified, write to output file // if image is specified, write to output file
let output_dir = std::env::current_dir()?; let output_dir = std::env::current_dir()?;
let now = chrono::Utc::now(); let now = chrono::Utc::now();
@@ -399,7 +397,7 @@ fn flash_boot(bootdevice: Option<String>, new_boot: PathBuf) -> Result<()> {
.arg(&bootdevice) .arg(&bootdevice)
.status()?; .status()?;
ensure!(status.success(), "set boot device rw failed"); ensure!(status.success(), "set boot device rw failed");
dd(&new_boot, &bootdevice).with_context(|| "flash boot failed")?; dd(new_boot, &bootdevice).with_context(|| "flash boot failed")?;
Ok(()) Ok(())
} }

View File

@@ -371,7 +371,7 @@ pub fn run() -> Result<()> {
boot, boot,
magiskboot, magiskboot,
flash, flash,
} => crate::boot_patch::restore(boot.unwrap(), magiskboot, flash), } => crate::boot_patch::restore(boot, magiskboot, flash),
}; };
if let Err(e) = &result { if let Err(e) = &result {