From 150ee7631eaeed641e75fcf2893b63cbd61fae34 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Thu, 11 Jan 2024 13:22:42 -0800 Subject: [PATCH] Desktop,Mobile,Cli: Fixes #8891: Fix AWS S3 sync error (#9696) --- packages/lib/file-api-driver-amazon-s3.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/lib/file-api-driver-amazon-s3.js b/packages/lib/file-api-driver-amazon-s3.js index 3b38bbb97..ec54664a1 100644 --- a/packages/lib/file-api-driver-amazon-s3.js +++ b/packages/lib/file-api-driver-amazon-s3.js @@ -175,6 +175,12 @@ class FileApiDriverAmazonS3 { } metadataToStats_(mds) { + // aws-sdk-js-v3 can rerturn undefined instead of an empty array when there is + // no metadata in some cases. + // + // Thus, we handle the !mds case. + if (!mds) return []; + const output = []; for (let i = 0; i < mds.length; i++) { output.push(this.metadataToStat_(mds[i], mds[i].Key)); @@ -212,10 +218,6 @@ class FileApiDriverAmazonS3 { let response = await this.s3ListObjects(prefixPath); - // In aws-sdk-js-v3 if there are no contents it no longer returns - // an empty array. This creates an Empty array to pass onward. - if (response.Contents === undefined) response.Contents = []; - let output = this.metadataToStats_(response.Contents, prefixPath); while (response.IsTruncated) {