Skip to content

Commit

Permalink
set creation time on mkdir
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgrammerIn-wonderland committed Oct 30, 2024
1 parent dd0dfc4 commit d64d53e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/api/LocalFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,23 @@ class LocalFS extends AFSProvider<LocalFSStats> {
},
mkdir: async (path: string) => {
let parentHandle = this.dirHandle;
let realParentPath = "";
path = this.relativizePath(path);
if (path.includes("/")) {
const parts = path.split("/");
const finalDir = parts.pop();
parentHandle = (
await this.getChildDirHandle(parts.join("/"))
)[0];
[parentHandle, realParentPath] = await this.getChildDirHandle(
parts.join("/"),
);
path = finalDir!;
}
const fullPath = realParentPath + "/" + path;
const fileStats = this.stats.get(fullPath) || {};
if (fileStats) {
fileStats.ctimeMs = Date.now();
this.stats.set(fullPath, fileStats);
}

await parentHandle.getDirectoryHandle(path, { create: true });
},
rmdir: async (path: string) => {
Expand Down Expand Up @@ -541,10 +549,13 @@ class LocalFS extends AFSProvider<LocalFSStats> {
chmod: async (fullPath: string, mode: number) => {
let path = this.relativizePath(fullPath);
if (path.endsWith("/")) path = path.slice(0, -1);

const currStats = this.stats.get(path) || {};
if (mode > 0o777) currStats.mode = mode;
else currStats.mode = 0o100000 + mode;

this.stats.set(path, currStats);

await this.promises.saveStats();
},
link: (existingPath: string, newPath: string): Promise<void> => {
Expand Down

0 comments on commit d64d53e

Please sign in to comment.