fix: (regression 0.57.0) faulty listing on Windows #977 #981
Massimo Melina committed
Apr 30, 2025 at 10:51 UTC
3f06a56321ee056f17b467e078b6ed48704aa4b6
1 file changed
+8
-10
src/walkDir.ts
+8
-10
@@ -64,10 +64,8 @@ export function walkDir(path: string, { depth = 0, hidden = true, ctx }: {
64
stats: { size: f.SIZE, birthtime: f.CREATION_TIME, mtime: f.LAST_WRITE_TIME } as Stats
65
}))
66
}, true))
67
- pluginReceiver?.(!stopped)
68
- return
67
}
70
- for await (let entry of (pluginIterator || await opendir(base))) {
68
+ else for await (let entry of (pluginIterator || await opendir(base))) {
69
if (stopped) break
70
if (!hidden && entry.name[0] === '.' && !IS_WINDOWS)
71
continue
@@ -81,6 +79,13 @@ export function walkDir(path: string, { depth = 0, hidden = true, ctx }: {
79
await work(expanded)
80
}
81
pluginReceiver?.(!stopped)
82
+ const branchDone = Promise.allSettled(subDirsDone)
83
+ if (last) // using streams, we don't know when the entries are received, so we need to notify on last item
84
+ last.closingBranch = branchDone.then(() => relativePath)
85
+ else
86
+ closingQ.push(relativePath) // ok, we'll ask next one to carry this info
87
+ // don't return the promise directly, as this job ends here, but communicate to caller the promise for the whole branch
88
+ return { branchDone, n }
89
90
async function work(entry: DirStreamEntry) {
91
entry.path = (relativePath && relativePath + '/') + entry.name
@@ -106,13 +111,6 @@ export function walkDir(path: string, { depth = 0, hidden = true, ctx }: {
111
dirQ.add(job) // this won't start until next tick
112
subDirsDone.push(branchDone)
113
}
109
- const branchDone = Promise.allSettled(subDirsDone).then(() => {})
110
- if (last) // using streams, we don't know when the entries are received, so we need to notify on last item
111
- last.closingBranch = branchDone.then(() => relativePath)
112
- else
113
- closingQ.push(relativePath) // ok, we'll ask next one to carry this info
114
- // don't return the promise directly, as this job ends here, but communicate to caller the promise for the whole branch
115
- return { branchDone, n }
114
}
115
}
116