1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-03 17:08:35 -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 David Sherret
parent f561e765a7
commit 1abcbb04b6
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) { function cache(desc, state) {
let { name: key } = desc; let { name: key } = desc;
if ( if (
(desc.name === "read" || desc.name === "write") && (desc.name === "read" || desc.name === "write" || desc.name === "ffi") &&
ReflectHas(desc, "path") ReflectHas(desc, "path")
) { ) {
key += `-${desc.path}`; key += `-${desc.path}&`;
} else if (desc.name === "net" && desc.host) { } 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)) { if (MapPrototypeHas(statusCache, key)) {
const status = MapPrototypeGet(statusCache, key); const status = MapPrototypeGet(statusCache, key);