mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 00:06:46 +01:00
scan media files in batches
This commit is contained in:
parent
19e39f6321
commit
61c32d99e7
@ -115,11 +115,16 @@ class MediaFileScanner {
|
|||||||
|
|
||||||
const scanStart = Date.now()
|
const scanStart = Date.now()
|
||||||
const mediaMetadata = libraryItem.media.metadata || null
|
const mediaMetadata = libraryItem.media.metadata || null
|
||||||
|
const batchSize = 32
|
||||||
|
const results = []
|
||||||
|
for (let batch = 0; batch < mediaLibraryFiles.length; batch += batchSize) {
|
||||||
const proms = []
|
const proms = []
|
||||||
for (let i = 0; i < mediaLibraryFiles.length; i++) {
|
for (let i = batch; i < Math.min(batch + batchSize, mediaLibraryFiles.length); i++) {
|
||||||
proms.push(this.scan(mediaType, mediaLibraryFiles[i], mediaMetadata))
|
proms.push(this.scan(mediaType, mediaLibraryFiles[i], mediaMetadata))
|
||||||
}
|
}
|
||||||
const results = await Promise.all(proms).then((scanResults) => scanResults.filter(sr => sr))
|
results.push(...await Promise.all(proms).then((scanResults) => scanResults.filter(sr => sr)))
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
audioFiles: results.filter(r => r.audioFile).map(r => r.audioFile),
|
audioFiles: results.filter(r => r.audioFile).map(r => r.audioFile),
|
||||||
videoFiles: results.filter(r => r.videoFile).map(r => r.videoFile),
|
videoFiles: results.filter(r => r.videoFile).map(r => r.videoFile),
|
||||||
|
Loading…
Reference in New Issue
Block a user