Skip to content

Commit

Permalink
Merge pull request #301 from supabase/bo/fix/wasm-cache-filename
Browse files Browse the repository at this point in the history
fix(wasm): add user id to wasm cache file hash
  • Loading branch information
burmecia authored Jul 7, 2024
2 parents d7c72a1 + 597fae4 commit 3ecda9e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions wrappers/src/fdw/wasm_fdw/wasm_fdw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ 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() },
url,
name,
version
));
let file_name = hex::encode(hash);
let mut path = dirs::cache_dir().expect("no cache dir found");
path.push(file_name);
Expand Down

0 comments on commit 3ecda9e

Please sign in to comment.