Merge remote-tracking branch 'origin/master' into feature/dynasm-backend

This commit is contained in:
losfair
2019-03-20 19:54:29 +08:00
5 changed files with 47 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ use std::{
};
use wasmer_runtime_core::cache::Error as CacheError;
pub use wasmer_runtime_core::cache::{Artifact, Cache, WasmHash};
pub use wasmer_runtime_core::cache::{Artifact, Cache, WasmHash, WASMER_VERSION_HASH};
/// Representation of a directory that contains compiled wasm artifacts.
///
@@ -40,12 +40,17 @@ pub struct FileSystemCache {
impl FileSystemCache {
/// Construct a new `FileSystemCache` around the specified directory.
/// The contents of the cache are stored in sub-versioned directories.
///
/// # Note:
/// 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<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() {
let metadata = path.metadata()?;