Skip to content

Commit

Permalink
fix: avoid running tmpfile init multiple times.
Browse files Browse the repository at this point in the history
  • Loading branch information
hughfenghen committed Jun 24, 2024
1 parent b44d501 commit 2423cb1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/tmpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,16 @@ export async function delMarkFiles() {
localStorage.setItem(opfsToolsExpires, markStr.replace(/,{2,}/g, ','));
}

declare global {
module globalThis {
var __opfs_tools_tmpfile_init__: boolean;
}
}

(async function init() {
if (globalThis.__opfs_tools_tmpfile_init__ === true) return;
globalThis.__opfs_tools_tmpfile_init__ = true;

// not web context
if (
globalThis.FileSystemDirectoryHandle == null ||
Expand Down

0 comments on commit 2423cb1

Please sign in to comment.