diff --git a/lib/runtime/src/cache.rs b/lib/runtime/src/cache.rs index af22f9696..4b2768bc6 100644 --- a/lib/runtime/src/cache.rs +++ b/lib/runtime/src/cache.rs @@ -46,7 +46,11 @@ impl FileSystemCache { /// This method is unsafe because there's no way to ensure the artifacts /// stored in this cache haven't been corrupted or tampered with. pub unsafe fn new>(path: P) -> io::Result { - let path: PathBuf = path.into(); + let path: PathBuf = { + let mut path = path.into(); + path.push(WASMER_VERSION_HASH); + path + }; if path.exists() { let metadata = path.metadata()?; @@ -85,7 +89,6 @@ impl Cache for FileSystemCache { fn load(&self, key: WasmHash) -> Result { let filename = key.encode(); let mut new_path_buf = self.path.clone(); - new_path_buf.push(WASMER_VERSION_HASH); new_path_buf.push(filename); let file = File::open(new_path_buf)?; let mmap = unsafe { Mmap::map(&file)? }; @@ -97,7 +100,6 @@ impl Cache for FileSystemCache { fn store(&mut self, key: WasmHash, module: Module) -> Result<(), CacheError> { let filename = key.encode(); let mut new_path_buf = self.path.clone(); - new_path_buf.push(WASMER_VERSION_HASH); new_path_buf.push(filename); let serialized_cache = module.cache()?; diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 115678dd7..bed968918 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -71,8 +71,8 @@ fn get_cache_dir() -> PathBuf { Err(_) => { // We use a temporal directory for saving cache files let mut temp_dir = env::temp_dir(); - temp_dir.push(WASMER_VERSION_HASH); temp_dir.push("wasmer"); + temp_dir.push(WASMER_VERSION_HASH); temp_dir } }