From 1ff21fc2a17eae5e47eb05d18b1513f8eb1b7aab Mon Sep 17 00:00:00 2001 From: ProgrammerIn-wonderland <3838shah@gmail.com> Date: Sat, 5 Oct 2024 16:31:36 -0400 Subject: [PATCH] mtime and utime --- src/api/LocalFS.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/api/LocalFS.ts b/src/api/LocalFS.ts index 04e01032..4fb6dbcc 100644 --- a/src/api/LocalFS.ts +++ b/src/api/LocalFS.ts @@ -289,6 +289,12 @@ class LocalFS extends AFSProvider { create: true, }); const writer = await handle.createWritable(); + const fileStats = this.stats.get(path) || {}; + if (fileStats) { + fileStats.mtimeMs = Date.now(); + fileStats.ctimeMs = Date.now(); + this.stats.set(path, fileStats); + } writer.write(data); writer.close(); }, @@ -315,6 +321,12 @@ class LocalFS extends AFSProvider { path = finalFile!; } const handle = await parentHandle.getFileHandle(path); + const fileStats = this.stats.get(path) || {}; + if (fileStats) { + fileStats.atimeMs = Date.now(); + this.stats.set(path, fileStats); + } + return new Filer.Buffer( await (await handle.getFile()).arrayBuffer(), ); @@ -737,8 +749,6 @@ class LocalFS extends AFSProvider { // Update the times in the file stats fileStats.atimeMs = accessTime.getTime(); fileStats.mtimeMs = modifiedTime.getTime(); - fileStats.atime = accessTime; - fileStats.mtime = modifiedTime; // Save the updated stats back into the stats map this.stats.set(path, fileStats);