Skip to content

Commit

Permalink
fixed fs.update
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed May 25, 2023
1 parent eef1c93 commit 1b09a91
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions core/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,19 @@ export default class FS {

/** Update the entry and returns it if it was removed */
update(path: string): Entry | undefined {
const entry = this.entries.get(path);

if (entry) {
try {
entry.removeCache();
entry.getInfo();
return;
} catch (error) {
// Remove if it doesn't exist
if (error instanceof Deno.errors.NotFound) {
this.removeEntry(path);
return entry;
}
const exist = this.entries.get(path);
const entry = exist || this.addEntry({ path });

try {
entry.removeCache();
entry.getInfo();
} catch (error) {
// Remove if it doesn't exist
if (error instanceof Deno.errors.NotFound) {
this.removeEntry(path);
return exist;
}
}

this.addEntry({ path });
}

#isValid(path: string) {
Expand Down Expand Up @@ -163,8 +159,12 @@ export default class FS {
}

if (!data.type) {
const info = Deno.statSync(data.src);
data.type = info.isDirectory ? "directory" : "file";
try {
const info = Deno.statSync(data.src);
data.type = info.isDirectory ? "directory" : "file";
} catch {
data.type = "file";
}
}

while (pieces.length > 1) {
Expand Down

0 comments on commit 1b09a91

Please sign in to comment.