mrmlnc / fast-glob

:rocket: It's a very fast and efficient glob library for Node.js
MIT License
2.55k stars 110 forks source link

fast glob ramdisk issue #431

Closed fawazahmed0 closed 11 months ago

fawazahmed0 commented 11 months ago

Environment

Actual behavior

cannot read files in ramdisk

Expected behavior

should read files in ramdisk …

I am not 100% sure whether it's due to ramdisk or what.

Ramdisk was created using

diskutil erasevolume HFS+ myramdisk $(hdiutil attach -nobrowse -nomount ram://2097152)

and is accessible in /Volumes/myramdisk.

I replaced the code

await fg(path.posix.join(...pathToDir.split(path.sep), '**'), { dot: true });

to

native node js version

// lists all files and directories in folder, returns full path
async function listDirRecursive(pathToDir, onlyFiles, onlyDir){
    let result = await fs.readdir(pathToDir,{withFileTypes:true, recursive:true})
    if(onlyFiles)
    result = result.filter(e=>e.isFile())
    else if(onlyDir)
    result = result.filter(e=>e.isDirectory())

    return result.map(e=>path.join(e.path,e.name))

 }

await listDirRecursive(pathToDir, true)

And everything works fine with native nodejs version.

I will close this issue, because my issue is already solved with native nodejs version, but just thought of letting you know.

Thanks