From 887c0e47b77835d178c3ad1cf3625b994b982738 Mon Sep 17 00:00:00 2001 From: Vo Van Nghia Date: Wed, 11 Dec 2024 10:08:04 +0100 Subject: [PATCH] chore: fix typed-path with encoding --- nghe-backend/src/config/cover_art.rs | 3 +-- nghe-backend/src/config/integration/mod.rs | 3 +-- nghe-backend/src/config/server.rs | 3 +-- nghe-backend/src/config/transcode.rs | 3 +-- nghe-backend/src/filesystem/local.rs | 7 +++---- nghe-backend/src/test/filesystem/mod.rs | 5 ++--- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/nghe-backend/src/config/cover_art.rs b/nghe-backend/src/config/cover_art.rs index ed8238bb..86ee8ba1 100644 --- a/nghe-backend/src/config/cover_art.rs +++ b/nghe-backend/src/config/cover_art.rs @@ -17,8 +17,7 @@ pub struct CoverArt { .join("nghe") .join("cache") .join("cover_art") - .with_platform_encoding_checked() - .unwrap() + .with_platform_encoding() ) ))] pub dir: Option, diff --git a/nghe-backend/src/config/integration/mod.rs b/nghe-backend/src/config/integration/mod.rs index 5ffca592..b2c4cf69 100644 --- a/nghe-backend/src/config/integration/mod.rs +++ b/nghe-backend/src/config/integration/mod.rs @@ -20,8 +20,7 @@ pub struct Spotify { .join("nghe") .join("spotify") .join("token.json") - .with_platform_encoding_checked() - .unwrap() + .with_platform_encoding() ) ))] pub token_path: Option, diff --git a/nghe-backend/src/config/server.rs b/nghe-backend/src/config/server.rs index c9938b7d..35aa0b38 100644 --- a/nghe-backend/src/config/server.rs +++ b/nghe-backend/src/config/server.rs @@ -18,8 +18,7 @@ pub struct Server { .unwrap() .join("frontend") .join("dist") - .with_platform_encoding_checked() - .unwrap() + .with_platform_encoding() ))] pub frontend_dir: Utf8PlatformPathBuf, } diff --git a/nghe-backend/src/config/transcode.rs b/nghe-backend/src/config/transcode.rs index 9b580750..11105e20 100644 --- a/nghe-backend/src/config/transcode.rs +++ b/nghe-backend/src/config/transcode.rs @@ -21,8 +21,7 @@ pub struct Transcode { .join("nghe") .join("cache") .join("transcode") - .with_platform_encoding_checked() - .unwrap() + .with_platform_encoding() ) ))] pub cache_dir: Option, diff --git a/nghe-backend/src/filesystem/local.rs b/nghe-backend/src/filesystem/local.rs index 01685b3c..5dafa3e7 100644 --- a/nghe-backend/src/filesystem/local.rs +++ b/nghe-backend/src/filesystem/local.rs @@ -82,10 +82,9 @@ impl super::Trait for Filesystem { offset: Option, ) -> Result { let path = match source.path.to_path() { - Utf8TypedPath::Unix(path) => path.with_platform_encoding_checked(), - Utf8TypedPath::Windows(path) => path.with_platform_encoding_checked(), - } - .map_err(|_| error::Kind::InvalidTypedPathPlatform(source.path.clone()))?; + Utf8TypedPath::Unix(path) => path.with_platform_encoding(), + Utf8TypedPath::Windows(path) => path.with_platform_encoding(), + }; binary::Response::from_path_property( path, diff --git a/nghe-backend/src/test/filesystem/mod.rs b/nghe-backend/src/test/filesystem/mod.rs index 02e1abc1..013ba8a7 100644 --- a/nghe-backend/src/test/filesystem/mod.rs +++ b/nghe-backend/src/test/filesystem/mod.rs @@ -36,9 +36,8 @@ impl Mock { pub fn prefix(&self) -> Utf8PlatformPathBuf { match self.local.prefix() { - Utf8TypedPath::Unix(path) => path.with_platform_encoding_checked(), - Utf8TypedPath::Windows(path) => path.with_platform_encoding_checked(), + Utf8TypedPath::Unix(path) => path.with_platform_encoding(), + Utf8TypedPath::Windows(path) => path.with_platform_encoding(), } - .unwrap() } }