From 60931b86c38b149a3220a3ac402e14642b050ffb Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Tue, 13 Oct 2020 09:53:19 +0100 Subject: [PATCH] Don't try to delete files if none are found in a directory --- libraries/object-persistor/src/GcsPersistor.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/object-persistor/src/GcsPersistor.js b/libraries/object-persistor/src/GcsPersistor.js index 3f7b7a5be3..a6a5e60186 100644 --- a/libraries/object-persistor/src/GcsPersistor.js +++ b/libraries/object-persistor/src/GcsPersistor.js @@ -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,