From e0f87299e2f9b24c6fb0e4881b1df60cbac1686e Mon Sep 17 00:00:00 2001 From: Bo Lu Date: Sun, 7 Jul 2024 13:31:51 +1000 Subject: [PATCH 1/2] fix(wasm): add user id to wasm cache file hash --- wrappers/src/fdw/wasm_fdw/wasm_fdw.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs b/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs index 04c4da97..07ab9b9f 100644 --- a/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs +++ b/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs @@ -74,9 +74,12 @@ fn download_component( // otherwise, download from custom url if it is not in local cache // calculate file name hash and make up cache path - let mut hasher = Sha256::new(); - hasher.update(format!("{}@{}", name, version)); - let hash = hasher.finalize(); + let hash = Sha256::digest(format!( + "{}:{}@{}", + unsafe { pg_sys::GetUserId().as_u32() }, + name, + version + )); let file_name = hex::encode(hash); let mut path = dirs::cache_dir().expect("no cache dir found"); path.push(file_name); From 597fae4ed3c66e359e9ea467a95ee0042369d46e Mon Sep 17 00:00:00 2001 From: Bo Lu Date: Sun, 7 Jul 2024 14:07:58 +1000 Subject: [PATCH 2/2] fix: add url to local cache file hash --- wrappers/src/fdw/wasm_fdw/wasm_fdw.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs b/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs index 07ab9b9f..969c9399 100644 --- a/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs +++ b/wrappers/src/fdw/wasm_fdw/wasm_fdw.rs @@ -75,8 +75,9 @@ fn download_component( // calculate file name hash and make up cache path let hash = Sha256::digest(format!( - "{}:{}@{}", + "{}:{}:{}@{}", unsafe { pg_sys::GetUserId().as_u32() }, + url, name, version ));