From 5c1a887b079ffa786c6ae9ab6ad3b463c9d62b93 Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Sat, 22 Jun 2024 23:33:27 +0800 Subject: [PATCH] add more hints for s3 --- src/fsS3.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/fsS3.ts b/src/fsS3.ts index 855f0cc..ef0c75f 100644 --- a/src/fsS3.ts +++ b/src/fsS3.ts @@ -309,7 +309,14 @@ const fromS3ObjectToEntity = ( ) => { // console.debug(`fromS3ObjectToEntity: ${x.Key!}, ${JSON.stringify(x,null,2)}`); // S3 officially only supports seconds precision!!!!! - const mtimeSvr = Math.floor(x.LastModified!.valueOf() / 1000.0) * 1000; + if (x.LastModified === undefined) { + throw Error( + `s3 object ${x.Key!} doesn't have LastModified value: ${JSON.stringify( + x + )}` + ); + } + const mtimeSvr = Math.floor(x.LastModified.valueOf() / 1000.0) * 1000; let mtimeCli = mtimeSvr; if (x.Key! in mtimeRecords) { const m2 = mtimeRecords[x.Key!]; @@ -346,7 +353,14 @@ const fromS3HeadObjectToEntity = ( ) => { // console.debug(`fromS3HeadObjectToEntity: ${fileOrFolderPathWithRemotePrefix}: ${JSON.stringify(x,null,2)}`); // S3 officially only supports seconds precision!!!!! - const mtimeSvr = Math.floor(x.LastModified!.valueOf() / 1000.0) * 1000; + if (x.LastModified === undefined) { + throw Error( + `s3 object ${fileOrFolderPathWithRemotePrefix} doesn't have LastModified value: ${JSON.stringify( + x + )}` + ); + } + const mtimeSvr = Math.floor(x.LastModified.valueOf() / 1000.0) * 1000; let mtimeCli = mtimeSvr; if (useAccurateMTime && x.Metadata !== undefined) { const m2 = Math.floor(