handle more cases of undefined in ListObjects replies
This commit is contained in:
parent
79c7ef3194
commit
70e4c9d64a
1 changed files with 16 additions and 10 deletions
26
deploy.ts
26
deploy.ts
|
@ -45,7 +45,7 @@ async function getFileMd5(file: string): Promise<string> {
|
|||
}
|
||||
|
||||
async function getBucketFiles(client: S3Client, Bucket: string):
|
||||
Promise<Map<string, { size: number }>>
|
||||
Promise<Map<string, { size: number | null }>>
|
||||
{
|
||||
const files = new Map();
|
||||
let done = false;
|
||||
|
@ -58,8 +58,12 @@ async function getBucketFiles(client: S3Client, Bucket: string):
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
for (const item of resp.Contents!) {
|
||||
files.set(item.Key!, { size: item.Size! })
|
||||
if (resp.Contents) {
|
||||
for (const item of resp.Contents) {
|
||||
if (item.Key) {
|
||||
files.set(item.Key, { size: item.Size })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resp.NextContinuationToken) {
|
||||
|
@ -125,14 +129,16 @@ async function needsUpdate(
|
|||
localMd5: string,
|
||||
Bucket: string,
|
||||
Key: string,
|
||||
remoteSize: number,
|
||||
remoteSize: number | null,
|
||||
): Promise<boolean> {
|
||||
const localSize = (await fs.promises.stat(localFile)).size;
|
||||
if (
|
||||
localSize == 0 /* stat can return 0 in case of error */
|
||||
|| localSize != remoteSize
|
||||
) {
|
||||
return true
|
||||
if (remoteSize) {
|
||||
const localSize = (await fs.promises.stat(localFile)).size;
|
||||
if (
|
||||
localSize == 0 /* stat can return 0 in case of error */
|
||||
|| localSize != remoteSize
|
||||
) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// fetch metadata for the object and see if we previously stored its md5
|
||||
|
|
Loading…
Add table
Reference in a new issue