Skip to content

Commit 52582f8

Browse files
yujincheng08backslashxx
authored andcommitted
Use tempfile (tiann#1980)
1 parent a411463 commit 52582f8

File tree

4 files changed

+59
-87
lines changed

4 files changed

+59
-87
lines changed

userspace/ksud/Cargo.lock

Lines changed: 34 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

userspace/ksud/Cargo.toml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
name = "ksud"
33
version = "0.1.0"
44
edition = "2021"
5-
rust-version = "1.77.2"
65

76
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
87

98
[dependencies]
10-
anyhow = "1"
11-
clap = { version = "4", features = ["derive"] }
9+
anyhow = "1.0"
10+
clap = { version = "4.5", features = ["derive"] }
1211
const_format = "0.2"
13-
zip = { version = "2.1.6", default-features = false }
14-
zip-extensions = { version = "0.8.1", features = [
12+
zip = { version = "2.1", default-features = false }
13+
zip-extensions = { version = "0.8", features = [
1514
"deflate",
1615
"deflate64",
1716
"time",
@@ -21,29 +20,29 @@ zip-extensions = { version = "0.8.1", features = [
2120
java-properties = { git = "https://github.com/Kernel-SU/java-properties.git", branch = "master", default-features = false }
2221
log = "0.4"
2322
env_logger = { version = "0.11", default-features = false }
24-
serde = { version = "1" }
25-
serde_json = "1"
23+
serde = { version = "1.0" }
24+
serde_json = "1.0"
2625
encoding_rs = "0.8"
27-
retry = "2"
28-
humansize = "2"
26+
retry = "2.0"
27+
humansize = "2.1"
2928
libc = "0.2"
30-
extattr = "1"
29+
extattr = "1.0"
3130
jwalk = "0.8"
32-
is_executable = "1"
33-
nom = "7"
31+
is_executable = "1.0"
32+
nom = "7.1"
3433
derive-new = "0.6"
35-
rust-embed = { version = "8", features = [
34+
rust-embed = { version = "8.5", features = [
3635
"debug-embed",
3736
"compression", # must clean build after updating binaries
3837
] }
39-
which = "6"
38+
which = "6.0"
4039
getopts = "0.2"
4140
sha256 = "1"
4241
sha1 = "0.10"
43-
tempdir = "0.3"
42+
tempfile = "3.12"
4443
chrono = "0.4"
4544
hole-punch = { git = "https://github.com/tiann/hole-punch" }
46-
regex-lite = "0.1.6"
45+
regex-lite = "0.1"
4746

4847
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
4948
rustix = { git = "https://github.com/Kernel-SU/rustix.git", branch = "main", features = [
@@ -61,3 +60,4 @@ android_logger = { version = "0.14", default-features = false }
6160
strip = true
6261
opt-level = "z"
6362
lto = true
63+
codegen-units = 1

userspace/ksud/src/boot_patch.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ pub fn restore(
211211
magiskboot_path: Option<PathBuf>,
212212
flash: bool,
213213
) -> Result<()> {
214-
let tmpdir = tempdir::TempDir::new("KernelSU").context("create temp dir failed")?;
214+
let tmpdir = tempfile::Builder::new()
215+
.prefix("KernelSU")
216+
.tempdir()
217+
.context("create temp dir failed")?;
215218
let workdir = tmpdir.path();
216219
let magiskboot = find_magiskboot(magiskboot_path, workdir)?;
217220

@@ -366,7 +369,10 @@ fn do_patch(
366369
);
367370
}
368371

369-
let tmpdir = tempdir::TempDir::new("KernelSU").context("create temp dir failed")?;
372+
let tmpdir = tempfile::Builder::new()
373+
.prefix("KernelSU")
374+
.tempdir()
375+
.context("create temp dir failed")?;
370376
let workdir = tmpdir.path();
371377

372378
// extract magiskboot

userspace/ksud/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fn find_temp_path() -> String {
206206
}
207207

208208
// Try to create a random directory in /dev/
209-
let r = tempdir::TempDir::new_in("/dev/", "");
209+
let r = tempfile::tempdir_in("/dev/");
210210
match r {
211211
Ok(tmp_dir) => {
212212
if let Some(path) = tmp_dir.into_path().to_str() {

0 commit comments

Comments
 (0)