From 6b6902372a7aa300a648865f5e5cd7ba1d8582b0 Mon Sep 17 00:00:00 2001 From: Bo Lu Date: Fri, 5 Jul 2024 00:24:33 +1000 Subject: [PATCH 1/2] fix(wasm): missing wasm package cache dir creation --- wrappers/src/fdw/wasm_fdw/README.md | 11 +++++++++++ wrappers/src/fdw/wasm_fdw/wasm_fdw.rs | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/wrappers/src/fdw/wasm_fdw/README.md b/wrappers/src/fdw/wasm_fdw/README.md index e69de29b..95cde061 100644 --- a/wrappers/src/fdw/wasm_fdw/README.md +++ b/wrappers/src/fdw/wasm_fdw/README.md @@ -0,0 +1,11 @@ +# Wasm Foreign Data Wrapper + +This is Wasm foreign data wrapper host, please visit each Wasm foreign data wrapper documentation. + +## Changelog + +| Version | Date | Notes | +| ------- | ---------- | ---------------------------------------------------- | +| 0.1.1 | 2024-07-05 | Fix missing wasm package cache dir issue | +| 0.1.0 | 2024-07-03 | Initial version | + diff --git a/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs b/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs index 433ed17d..3cff93c3 100644 --- a/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs +++ b/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs @@ -86,7 +86,11 @@ fn download_component( // download component wasm from remote and save it to local cache let resp = rt.block_on(reqwest::get(url))?; let bytes = rt.block_on(resp.bytes())?; - fs::write(&path, bytes)?; + if let Some(parent) = path.parent() { + // create all parent directories if they do not exist + fs::create_dir_all(parent).expect("should create cache folder"); + } + fs::write(&path, bytes).expect("should save fdw package"); } Ok(Component::from_file(engine, &path).map_err(|err| { @@ -97,7 +101,7 @@ fn download_component( } #[wrappers_fdw( - version = "0.1.0", + version = "0.1.1", author = "Supabase", website = "https://github.com/supabase/wrappers/tree/main/wrappers/src/fdw/wasm_fdw", error_type = "WasmFdwError" From af8fea94b2f9061234abb26afdb3baaa42e00d2c Mon Sep 17 00:00:00 2001 From: Bo Lu Date: Fri, 5 Jul 2024 00:35:44 +1000 Subject: [PATCH 2/2] remove expect --- wrappers/src/fdw/wasm_fdw/wasm_fdw.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs b/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs index 3cff93c3..04c4da97 100644 --- a/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs +++ b/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs @@ -88,9 +88,9 @@ fn download_component( let bytes = rt.block_on(resp.bytes())?; if let Some(parent) = path.parent() { // create all parent directories if they do not exist - fs::create_dir_all(parent).expect("should create cache folder"); + fs::create_dir_all(parent)?; } - fs::write(&path, bytes).expect("should save fdw package"); + fs::write(&path, bytes)?; } Ok(Component::from_file(engine, &path).map_err(|err| {