Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(loader/cache): add data dir fallback if wasm layer not found #1941

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion crates/loader/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ impl Cache {

/// Return the path to a wasm file given its digest.
pub fn wasm_file(&self, digest: impl AsRef<str>) -> Result<PathBuf> {
let path = self.wasm_path(&digest);
// Check the expected wasm directory first; else check the data directory as a fallback.
// (Layers with unknown media types are currently saved to the data directory in client.pull())
// This adds a bit of futureproofing for fetching wasm layers with different/updated media types
// (see WASM_LAYER_MEDIA_TYPE, which is subject to change in future versions).
let mut path = self.wasm_path(&digest);
if !path.exists() {
path = self.data_path(&digest);
}
ensure!(
path.exists(),
"cannot find wasm file for digest {}",
Expand Down