From b1aa7570b558f52e52ee51d4e3efe5914e1392a2 Mon Sep 17 00:00:00 2001 From: Hsu Zhong Jun <27919917+dcshzj@users.noreply.github.com> Date: Tue, 14 Nov 2023 18:28:44 +0800 Subject: [PATCH] fix: use cTimeMs instead of birthtime due to EFS --- src/services/db/GitFileSystemService.ts | 4 ++-- .../db/__tests__/GitFileSystemService.spec.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/services/db/GitFileSystemService.ts b/src/services/db/GitFileSystemService.ts index 0fa608247..9c8b42a9b 100644 --- a/src/services/db/GitFileSystemService.ts +++ b/src/services/db/GitFileSystemService.ts @@ -858,7 +858,7 @@ export default class GitFileSystemService { mediaUrl: `${dataUrlPrefix},${file.content}`, mediaPath: `${directoryName}/${fileName}`, type: fileType, - addedTime: stats.birthtimeMs, + addedTime: stats.ctimeMs, size: stats.size, }) }) @@ -929,7 +929,7 @@ export default class GitFileSystemService { sha, path, size: type === "dir" ? 0 : stats.size, - addedTime: stats.birthtimeMs, + addedTime: stats.ctimeMs, } return okAsync(result) diff --git a/src/services/db/__tests__/GitFileSystemService.spec.ts b/src/services/db/__tests__/GitFileSystemService.spec.ts index 1b0c0e777..a6887c2c5 100644 --- a/src/services/db/__tests__/GitFileSystemService.spec.ts +++ b/src/services/db/__tests__/GitFileSystemService.spec.ts @@ -91,7 +91,7 @@ describe("GitFileSystemService", () => { path: "fake-dir", size: 0, addedTime: fs.statSync(`${EFS_VOL_PATH_STAGING}/fake-repo/fake-dir`) - .birthtimeMs, + .ctimeMs, } const expectedAnotherFakeDir: GitDirectoryItem = { name: "another-fake-dir", @@ -101,7 +101,7 @@ describe("GitFileSystemService", () => { size: 0, addedTime: fs.statSync( `${EFS_VOL_PATH_STAGING}/fake-repo/another-fake-dir` - ).birthtimeMs, + ).ctimeMs, } const expectedFakeEmptyDir: GitDirectoryItem = { name: "fake-empty-dir", @@ -111,7 +111,7 @@ describe("GitFileSystemService", () => { size: 0, addedTime: fs.statSync( `${EFS_VOL_PATH_STAGING}/fake-repo/fake-empty-dir` - ).birthtimeMs, + ).ctimeMs, } const expectedAnotherFakeFile: GitDirectoryItem = { name: "another-fake-file", @@ -121,7 +121,7 @@ describe("GitFileSystemService", () => { size: "Another fake content".length, addedTime: fs.statSync( `${EFS_VOL_PATH_STAGING}/fake-repo/another-fake-file` - ).birthtimeMs, + ).ctimeMs, } const result = await GitFileSystemService.listDirectoryContents( @@ -162,7 +162,7 @@ describe("GitFileSystemService", () => { path: "fake-dir", size: 0, addedTime: fs.statSync(`${EFS_VOL_PATH_STAGING}/fake-repo/fake-dir`) - .birthtimeMs, + .ctimeMs, } const expectedAnotherFakeFile: GitDirectoryItem = { name: "another-fake-file", @@ -172,7 +172,7 @@ describe("GitFileSystemService", () => { size: "Another fake content".length, addedTime: fs.statSync( `${EFS_VOL_PATH_STAGING}/fake-repo/another-fake-file` - ).birthtimeMs, + ).ctimeMs, } const result = await GitFileSystemService.listDirectoryContents( @@ -1429,7 +1429,7 @@ describe("GitFileSystemService", () => { ).toString("base64")}`, mediaPath: "fake-dir/fake-media-file.png", type: "file", - addedTime: fileStats.birthtimeMs, + addedTime: fileStats.ctimeMs, size: fileStats.size, }