Skip to content

Commit

Permalink
fix mkdtemp
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgrammerIn-wonderland committed Oct 5, 2024
1 parent d6b061d commit 9ec6afc
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/api/LocalFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ class LocalFS extends AFSProvider<LocalFSStats> {
// @ts-ignore - This is just here for compat with v86
return this.promises.stat(...args);
},
mkdtemp(template: string): Promise<string> {
mkdtemp: (template: string): Promise<string> => {
return new Promise((resolve, reject) => {
// Check if template has 'XXXXXX'
if (!template.includes("XXXXXX")) {
Expand All @@ -578,17 +578,6 @@ class LocalFS extends AFSProvider<LocalFSStats> {
// Replace 'XXXXXX' in the template with the random suffix
const newDir = template.replace("XXXXXX", randomSuffix);

// Check if directory already exists (edge case)
if (this.stats.has(newDir)) {
return reject({
name: "EEXIST",
code: "EEXIST",
errno: -17,
message: `Directory already exists: ${newDir}`,
stack: "Error: Directory exists",
} as Error);
}

// Add the new directory to stats
this.stats.set(newDir, {
dev: 1,
Expand All @@ -605,10 +594,10 @@ class LocalFS extends AFSProvider<LocalFSStats> {
mtimeMs: Date.now(),
ctimeMs: Date.now(),
birthtimeMs: Date.now(),
isDirectory: () => true,
isFile: () => false,
isDirectory: true,
isFile: false,
});

this.promises.mkdir(newDir);
// Save the new stats
this.promises
.saveStats()
Expand Down

0 comments on commit 9ec6afc

Please sign in to comment.