Skip to content

Commit

Permalink
fix: 修复windows环境使用sc时,获取执行输出信息失败问题
Browse files Browse the repository at this point in the history
  • Loading branch information
SerenitySir committed Jul 23, 2024
1 parent 0f141ef commit 01bed51
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async-trait = "0.1.77"
time = { version = "0.3.36", features = ["parsing", "macros"] }
#rc4 = "0.1.0"

service-manager = "0.6.1"
service-manager = "0.7"

reqwest = { version = "0.11", features = ["json"] }

Expand All @@ -33,3 +33,16 @@ serde_yaml = "0.9.32"

anyhow = "1.0.86"
thiserror = "1.0.62"

[build-dependencies]
cargo-patch = "0.3"

[package.metadata.patch.service-manager]
version = "0.7"
patches = [
"patches/sc.patch",
"patches/service-manager-cargo.patch"
]

[patch.crates-io]
service-manager = { path = './target/patch/service-manager-0.7.1' }
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
println!("cargo:rerun-if-changed=Cargo.toml");
println!("cargo:rerun-if-changed=patches/");
cargo_patch::patch().expect("Failed while patching");
}
18 changes: 18 additions & 0 deletions patches/sc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- src/sc.rs
+++ src/sc.rs
@@ -283,11 +283,11 @@
if output.status.success() {
Ok(())
} else {
- let msg = String::from_utf8(output.stderr)
+ use encoding::all::GBK;
+ use encoding::{DecoderTrap, Encoding};
+ let msg = GBK.decode(&*output.stderr, DecoderTrap::Replace)
.ok()
.filter(|s| !s.trim().is_empty())
.or_else(|| {
- String::from_utf8(output.stdout)
+ GBK.decode(&*output.stdout, DecoderTrap::Replace)
.ok()
.filter(|s| !s.trim().is_empty())
})
8 changes: 8 additions & 0 deletions patches/service-manager-cargo.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--- Cargo.toml
+++ Cargo.toml
@@ -25,11 +25,11 @@
[dependencies.cfg-if]
version = "1.0"
+
+[dependencies.encoding]
+version = "0.2"

0 comments on commit 01bed51

Please sign in to comment.