Skip to content

Commit ef3998b

Browse files
authored
Merge pull request #1941 from vdice/feat/wasm-cache-fallback
feat(loader/cache): add data dir fallback if wasm layer not found
2 parents 5376331 + 8e7f515 commit ef3998b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crates/loader/src/cache.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ impl Cache {
5050

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

0 commit comments

Comments
 (0)