Skip to content

Commit

Permalink
Refactor FileSystemCache::new to only have one ending
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Apr 20, 2023
1 parent cea6e88 commit 75a06f0
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions packages/vm/src/modules/file_system_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,24 @@ impl FileSystemCache {
let metadata = base_path
.metadata()
.map_err(|_e| NewFileSystemCacheError::CouldntGetMetadata)?;
if metadata.is_dir() {
if !metadata.permissions().readonly() {
Ok(Self {
modules_path: modules_path(
&base_path,
current_wasmer_module_version(),
&Target::default(),
),
})
} else {
Err(NewFileSystemCacheError::ReadonlyPath)
}
} else {
Err(NewFileSystemCacheError::ExistsButNoDirectory)
if !metadata.is_dir() {
return Err(NewFileSystemCacheError::ExistsButNoDirectory);
}
if metadata.permissions().readonly() {
return Err(NewFileSystemCacheError::ReadonlyPath);
}
} else {
// Create the directory and any parent directories if they don't yet exist.
mkdir_p(&base_path).map_err(|_e| NewFileSystemCacheError::CouldntCreatePath)?;
Ok(Self {
modules_path: modules_path(
&base_path,
current_wasmer_module_version(),
&Target::default(),
),
})
}

Ok(Self {
modules_path: modules_path(
&base_path,
current_wasmer_module_version(),
&Target::default(),
),
})
}

/// Loads a serialized module from the file system and returns a module (i.e. artifact + store),
Expand Down

0 comments on commit 75a06f0

Please sign in to comment.