1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(runtime): fix permission status cache keys (#15899)

This commit is contained in:
Nayeem Rahman 2022-09-16 12:46:38 +01:00 committed by GitHub
parent ee208c1b20
commit 38280990da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View file

@ -86,3 +86,11 @@ Deno.test(async function permissionDescriptorValidation() {
}
}
});
// Regression test for https://github.com/denoland/deno/issues/15894.
Deno.test(async function permissionStatusObjectsNotEqual() {
assert(
await Deno.permissions.query({ name: "env", variable: "A" }) !=
await Deno.permissions.query({ name: "env", variable: "B" }),
);
});

View file

@ -122,12 +122,18 @@
function cache(desc, state) {
let { name: key } = desc;
if (
(desc.name === "read" || desc.name === "write") &&
(desc.name === "read" || desc.name === "write" || desc.name === "ffi") &&
ReflectHas(desc, "path")
) {
key += `-${desc.path}`;
key += `-${desc.path}&`;
} else if (desc.name === "net" && desc.host) {
key += `-${desc.host}`;
key += `-${desc.host}&`;
} else if (desc.name === "run" && desc.command) {
key += `-${desc.command}&`;
} else if (desc.name === "env" && desc.variable) {
key += `-${desc.variable}&`;
} else {
key += "$";
}
if (MapPrototypeHas(statusCache, key)) {
const status = MapPrototypeGet(statusCache, key);