refactor: replace &PathBuf with &Path to enhance generality (#10332)

This commit is contained in:
Integral
2024-12-23 20:28:04 +08:00
committed by GitHub
parent 7289dbc80f
commit 49dabd3533
13 changed files with 44 additions and 40 deletions

View File

@@ -452,7 +452,7 @@ pub(super) mod install {
use std::{
fs::File,
io::{BufReader, BufWriter, Write},
path::PathBuf,
path::Path,
};
use zip::ZipArchive;
@@ -488,7 +488,7 @@ pub(super) mod install {
Ok(())
}
fn download_file(id: &str, url: &str, filename: &PathBuf) -> bool {
fn download_file(id: &str, url: &str, filename: &Path) -> bool {
let file = match File::create(filename) {
Ok(f) => f,
Err(e) => {
@@ -505,7 +505,7 @@ pub(super) mod install {
true
}
fn do_install_file(filename: &PathBuf, target_dir: &PathBuf) -> ResultType<()> {
fn do_install_file(filename: &Path, target_dir: &Path) -> ResultType<()> {
let mut zip = ZipArchive::new(BufReader::new(File::open(filename)?))?;
for i in 0..zip.len() {
let mut file = zip.by_index(i)?;