AsyncPool -> asyncPool

This commit is contained in:
Simon Detheridge 2020-07-31 16:21:59 +01:00
parent 9724407e31
commit cb8c2bf4b5

View file

@ -7,7 +7,7 @@ const crypto = require('crypto')
const Streamifier = require('streamifier') const Streamifier = require('streamifier')
const RangeManager = require('./RangeManager') const RangeManager = require('./RangeManager')
const PersistorManager = require('./PersistorManager') const PersistorManager = require('./PersistorManager')
const AsyncPool = require('tiny-async-pool') const asyncPool = require('tiny-async-pool')
const PARALLEL_JOBS = 5 const PARALLEL_JOBS = 5
@ -39,7 +39,7 @@ async function archiveAllDocs(projectId) {
throw new Errors.NotFoundError(`No docs for project ${projectId}`) throw new Errors.NotFoundError(`No docs for project ${projectId}`)
} }
await AsyncPool( await asyncPool(
PARALLEL_JOBS, PARALLEL_JOBS,
docs.filter((doc) => !doc.inS3), docs.filter((doc) => !doc.inS3),
(doc) => archiveDoc(projectId, doc) (doc) => archiveDoc(projectId, doc)
@ -85,10 +85,10 @@ async function unArchiveAllDocs(projectId) {
throw new Errors.NotFoundError(`No docs for project ${projectId}`) throw new Errors.NotFoundError(`No docs for project ${projectId}`)
} }
if (!docs.length) { if (!docs.length) {
// AsyncPool will throw an error with an empty array // asyncPool will throw an error with an empty array
return return
} }
await AsyncPool(PARALLEL_JOBS, docs, (doc) => await asyncPool(PARALLEL_JOBS, docs, (doc) =>
unarchiveDoc(projectId, doc._id) unarchiveDoc(projectId, doc._id)
) )
} }
@ -141,8 +141,8 @@ async function destroyAllDocs(projectId) {
{ include_deleted: true }, { include_deleted: true },
{ _id: 1 } { _id: 1 }
) )
if (docs) { if (docs && docs.length) {
await AsyncPool(PARALLEL_JOBS, docs, (doc) => await asyncPool(PARALLEL_JOBS, docs, (doc) =>
destroyDoc(projectId, doc._id) destroyDoc(projectId, doc._id)
) )
} }