Skip to content

Commit

Permalink
mtime and utime
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgrammerIn-wonderland committed Oct 5, 2024
1 parent 8ccb6f2 commit 1ff21fc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/api/LocalFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ class LocalFS extends AFSProvider<LocalFSStats> {
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();
},
Expand All @@ -315,6 +321,12 @@ class LocalFS extends AFSProvider<LocalFSStats> {
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(),
);
Expand Down Expand Up @@ -737,8 +749,6 @@ class LocalFS extends AFSProvider<LocalFSStats> {
// 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);
Expand Down

0 comments on commit 1ff21fc

Please sign in to comment.