Skip to content

Commit ba98a0e

Browse files
committed
update clean function
1 parent 6f35120 commit ba98a0e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ MusicLibrary.prototype.clean = function (opts, cb) {
142142
var levelBatch = new LevelBatch(this.db)
143143
var paralleLevelBatch = parallel(levelBatch, opts.parallel || 10)
144144

145+
var paths = this.paths
146+
145147
function operation (chunk) {
146148
var key = keyFn(chunk.value.filepath)
147149
return {
@@ -151,12 +153,20 @@ MusicLibrary.prototype.clean = function (opts, cb) {
151153
}
152154

153155
function fsStat (chunk, enc, cb) {
156+
if (!paths.some(areIncluded)) {
157+
this.push(chunk)
158+
return cb()
159+
}
154160
fs.stat(chunk.value.filepath, pushMissing.bind(this))
155161

156162
function pushMissing (err, value) {
157163
if (err) this.push(chunk)
158164
return cb()
159165
}
166+
167+
function areIncluded (path) {
168+
return path === chunk.value.root
169+
}
160170
}
161171

162172
return pump(

0 commit comments

Comments
 (0)