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

fix(#4850): Deno.remove() fails to remove unix socket (#5967)

This commit is contained in:
uki00a 2020-05-31 03:48:26 +09:00 committed by GitHub
parent 550556e948
commit 64bd2768f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View file

@ -417,8 +417,11 @@ fn op_remove(
std::fs::remove_file(&path)?;
}
}
} else {
} else if file_type.is_dir() {
std::fs::remove_dir(&path)?;
} else {
// pipes, sockets, etc...
std::fs::remove_file(&path)?;
}
Ok(json!({}))
})

View file

@ -460,6 +460,31 @@ unitTest({ perms: { write: false } }, async function removeAllPerm(): Promise<
assertEquals(err.name, "PermissionDenied");
});
unitTest(
{
ignore: Deno.build.os === "windows",
perms: { write: true, read: true },
},
async function removeUnixSocketSuccess(): Promise<void> {
for (const method of ["remove", "removeSync"] as const) {
// MAKE TEMPORARY UNIX SOCKET
const path = Deno.makeTempDirSync() + "/test.sock";
const listener = Deno.listen({ transport: "unix", path });
listener.close();
Deno.statSync(path); // check if unix socket exists
await Deno[method](path);
let err;
try {
Deno.statSync(path);
} catch (e) {
err = e;
}
assert(err instanceof Deno.errors.NotFound);
}
}
);
if (Deno.build.os === "windows") {
unitTest(
{ perms: { run: true, write: true, read: true } },