From 404a019c56d816a1f4b4e057d7019bb526bba6f1 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 28 Sep 2017 10:36:56 -0700 Subject: [PATCH] s3: Check IsTruncated before accessing Contents --- src/storage/s3.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/storage/s3.js b/src/storage/s3.js index 1de5c18b5..fe58f5dc0 100644 --- a/src/storage/s3.js +++ b/src/storage/s3.js @@ -178,13 +178,13 @@ function listDir(apiConfig, backupFilePath, options, iteratorCallback, callback) async.eachLimit(arr, options.concurrency, iteratorCallback.bind(null, s3), function iteratorDone(error) { if (error) return foreverCallback(error); - total += listData.Contents.length; + total += listData.KeyCount; + + if (!listData.IsTruncated) return foreverCallback(new Error('Done')); listParams.StartAfter = listData.Contents[listData.Contents.length - 1].Key; // NextMarker is returned only with delimiter - if (listData.IsTruncated) return foreverCallback(); - - foreverCallback(new Error('Done')); + foreverCallback(); }); }); }, function (error) {