Skip to content

Commit

Permalink
chore: fix typed-path with encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
vnghia committed Dec 11, 2024
1 parent f7a8825 commit 887c0e4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 15 deletions.
3 changes: 1 addition & 2 deletions nghe-backend/src/config/cover_art.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Utf8PlatformPathBuf>,
Expand Down
3 changes: 1 addition & 2 deletions nghe-backend/src/config/integration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Utf8PlatformPathBuf>,
Expand Down
3 changes: 1 addition & 2 deletions nghe-backend/src/config/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ pub struct Server {
.unwrap()
.join("frontend")
.join("dist")
.with_platform_encoding_checked()
.unwrap()
.with_platform_encoding()
))]
pub frontend_dir: Utf8PlatformPathBuf,
}
Expand Down
3 changes: 1 addition & 2 deletions nghe-backend/src/config/transcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Utf8PlatformPathBuf>,
Expand Down
7 changes: 3 additions & 4 deletions nghe-backend/src/filesystem/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ impl super::Trait for Filesystem {
offset: Option<u64>,
) -> Result<binary::Response, Error> {
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,
Expand Down
5 changes: 2 additions & 3 deletions nghe-backend/src/test/filesystem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

0 comments on commit 887c0e4

Please sign in to comment.