Don't try to delete files if none are found in a directory

This commit is contained in:
Simon Detheridge 2020-10-13 09:53:19 +01:00
parent 65c5793b48
commit 60931b86c3

View file

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