Skip to content

Commit

Permalink
fix(utils): wrong pathname is registered in the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
hulxv committed Sep 20, 2024
1 parent 306ffd7 commit 648981a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/metassr-utils/src/cache_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ impl CacheDir {
/// cache.insert("data.txt", "Some data".as_bytes()).unwrap();
/// ```
pub fn insert(&mut self, pathname: &str, buf: &[u8]) -> Result<PathBuf> {
let pathname = format!("{}/{}", self.dir_path.to_str().unwrap(), pathname);
let path = Path::new(&pathname);

// Set the path
let path = format!("{}/{}", self.dir_path.to_str().unwrap(), pathname);
let path = Path::new(&path);

// Create file path if it doesn't exist
if !path.exists() {
Expand All @@ -112,7 +114,8 @@ impl CacheDir {

// Add the new file path to the cache entries
self.entries_in_scope
.insert(pathname.clone(), path.canonicalize()?);
.insert(pathname.to_string(), path.canonicalize()?);

Ok(path.to_path_buf())
}

Expand Down

0 comments on commit 648981a

Please sign in to comment.