mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-21 12:41:32 +00:00
fix bugs and clean up path logic
This commit is contained in:
@ -46,7 +46,11 @@ impl FileSystemCache {
|
|||||||
/// This method is unsafe because there's no way to ensure the artifacts
|
/// This method is unsafe because there's no way to ensure the artifacts
|
||||||
/// stored in this cache haven't been corrupted or tampered with.
|
/// stored in this cache haven't been corrupted or tampered with.
|
||||||
pub unsafe fn new<P: Into<PathBuf>>(path: P) -> io::Result<Self> {
|
pub unsafe fn new<P: Into<PathBuf>>(path: P) -> io::Result<Self> {
|
||||||
let path: PathBuf = path.into();
|
let path: PathBuf = {
|
||||||
|
let mut path = path.into();
|
||||||
|
path.push(WASMER_VERSION_HASH);
|
||||||
|
path
|
||||||
|
};
|
||||||
|
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
let metadata = path.metadata()?;
|
let metadata = path.metadata()?;
|
||||||
@ -85,7 +89,6 @@ impl Cache for FileSystemCache {
|
|||||||
fn load(&self, key: WasmHash) -> Result<Module, CacheError> {
|
fn load(&self, key: WasmHash) -> Result<Module, CacheError> {
|
||||||
let filename = key.encode();
|
let filename = key.encode();
|
||||||
let mut new_path_buf = self.path.clone();
|
let mut new_path_buf = self.path.clone();
|
||||||
new_path_buf.push(WASMER_VERSION_HASH);
|
|
||||||
new_path_buf.push(filename);
|
new_path_buf.push(filename);
|
||||||
let file = File::open(new_path_buf)?;
|
let file = File::open(new_path_buf)?;
|
||||||
let mmap = unsafe { Mmap::map(&file)? };
|
let mmap = unsafe { Mmap::map(&file)? };
|
||||||
@ -97,7 +100,6 @@ impl Cache for FileSystemCache {
|
|||||||
fn store(&mut self, key: WasmHash, module: Module) -> Result<(), CacheError> {
|
fn store(&mut self, key: WasmHash, module: Module) -> Result<(), CacheError> {
|
||||||
let filename = key.encode();
|
let filename = key.encode();
|
||||||
let mut new_path_buf = self.path.clone();
|
let mut new_path_buf = self.path.clone();
|
||||||
new_path_buf.push(WASMER_VERSION_HASH);
|
|
||||||
new_path_buf.push(filename);
|
new_path_buf.push(filename);
|
||||||
|
|
||||||
let serialized_cache = module.cache()?;
|
let serialized_cache = module.cache()?;
|
||||||
|
@ -71,8 +71,8 @@ fn get_cache_dir() -> PathBuf {
|
|||||||
Err(_) => {
|
Err(_) => {
|
||||||
// We use a temporal directory for saving cache files
|
// We use a temporal directory for saving cache files
|
||||||
let mut temp_dir = env::temp_dir();
|
let mut temp_dir = env::temp_dir();
|
||||||
temp_dir.push(WASMER_VERSION_HASH);
|
|
||||||
temp_dir.push("wasmer");
|
temp_dir.push("wasmer");
|
||||||
|
temp_dir.push(WASMER_VERSION_HASH);
|
||||||
temp_dir
|
temp_dir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user