Upcloud S3 does not return a Contents property if no keys are found

This commit is contained in:
Johannes Zellner
2025-07-22 18:55:44 +02:00
parent 9e907f10b1
commit 2386124089
+2 -2
View File
@@ -221,7 +221,7 @@ async function exists(apiConfig, backupFilePath) {
const [error, listData] = await safe(s3.listObjectsV2(listParams));
if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, `Error listing objects ${backupFilePath}. ${formatError(error)}`);
return listData.Contents.length !== 0;
return listData.KeyCount !== 0 || listData.Contents.length !== 0;
}
}
@@ -334,7 +334,7 @@ async function listDir(apiConfig, dir, batchSize, marker) {
const [error, listData] = await safe(s3.listObjectsV2(listParams));
if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, `Error listing objects in ${dir}. ${formatError(error)}`);
if (listData.Contents.length === 0) return { entries: [], marker: null }; // no more
if (listData.KeyCount === 0 || listData.Contents.length === 0) return { entries: [], marker: null }; // no more
const entries = listData.Contents.map(function (c) { return { fullPath: c.Key, size: c.Size }; });
return { entries, marker: !listData.IsTruncated ? null : listData.NextContinuationToken };
}