From 87c5a7770b234eb45a6bc3ab12f4c8b5f938af66 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sat, 9 Jul 2022 12:28:33 -0400 Subject: [PATCH] Fix read_single parsing failure due to \n --- Cargo.lock | 2 +- usdpl-back/Cargo.toml | 2 +- usdpl-back/src/api_common/files.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9f28ea..edeeb8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -926,7 +926,7 @@ dependencies = [ [[package]] name = "usdpl-back" -version = "0.5.0" +version = "0.5.2" dependencies = [ "bytes", "tokio", diff --git a/usdpl-back/Cargo.toml b/usdpl-back/Cargo.toml index 31cd5ae..95bedaf 100644 --- a/usdpl-back/Cargo.toml +++ b/usdpl-back/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "usdpl-back" -version = "0.5.1" +version = "0.5.3" edition = "2021" license = "GPL-3.0-only" repository = "https://github.com/NGnius/usdpl-rs" diff --git a/usdpl-back/src/api_common/files.rs b/usdpl-back/src/api_common/files.rs index 8193f47..b5cb1c5 100644 --- a/usdpl-back/src/api_common/files.rs +++ b/usdpl-back/src/api_common/files.rs @@ -15,7 +15,7 @@ pub fn write_single, D: Display>(path: P, display: D) -> Result<( /// Read something from a file. /// Useful for kernel configuration files. pub fn read_single, D: FromStr, E>(path: P) -> Result, Option)> { - let mut file = File::create(path).map_err(|e| (Some(e), None))?; + let mut file = File::open(path).map_err(|e| (Some(e), None))?; let mut string = String::new(); file.read_to_string(&mut string).map_err(|e| (Some(e), None))?; string.trim().parse().map_err(|e| (None, Some(e)))