gojs: ensures Mkdir(path, 0) works (#1208)

Go has a test that forces us to handle Mkdir with zero as its
permissions. In GOOS=js, the result of fs.mkdir is a file descriptor,
and to open that, we can't use literally 0. Hence, to solve this we need
to coerce 0 to 0500 in GOOS=js.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2023-03-07 16:02:17 +08:00
committed by GitHub
parent 86d89e4d6a
commit 6626535f44
3 changed files with 17 additions and 4 deletions

View File

@@ -454,6 +454,10 @@ func (jsfsMkdir) invoke(ctx context.Context, mod api.Module, args ...interface{}
var fd uint32
var err error
// We need at least read access to open the file descriptor
if perm == 0 {
perm = 0o0500
}
if err = root.Mkdir(path, fs.FileMode(perm)); err == nil {
fd, err = fsc.OpenFile(root, path, os.O_RDONLY, 0)
}