Merge pull request #12 from overleaf/spd-async-pool-empty-array

Don't try to delete files if none are found in a directory
This commit is contained in:
Simon Detheridge 2020-10-13 10:01:20 +01:00 committed by GitHub
commit 9f28adf96c

View file

@ -220,9 +220,15 @@ module.exports = class GcsPersistor extends AbstractPersistor {
.bucket(bucketName) .bucket(bucketName)
.getFiles({ directory: key }) .getFiles({ directory: key })
await asyncPool(this.settings.deleteConcurrency, files, async (file) => { if (Array.isArray(files) && files.length > 0) {
await asyncPool(
this.settings.deleteConcurrency,
files,
async (file) => {
await this.deleteObject(bucketName, file.name) await this.deleteObject(bucketName, file.name)
}) }
)
}
} catch (err) { } catch (err) {
const error = PersistorHelper.wrapError( const error = PersistorHelper.wrapError(
err, err,