Skip to content

Commit

Permalink
Fixed IndexedDB.isAvailable not returning true on success
Browse files Browse the repository at this point in the history
Upgraded to core 0.4
Fixed build script
  • Loading branch information
james-pre committed Mar 22, 2024
1 parent a2a70f5 commit a9c40c6
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 22 deletions.
81 changes: 64 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@
"typescript": "5.2.2"
},
"peerDependencies": {
"@browserfs/core": "^0.3.2"
"@browserfs/core": "^0.4.0"
}
}
2 changes: 1 addition & 1 deletion scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ctx = await context({
}

try {
execSync('tsc -p tsconfig.json');
execSync('npx tsc -p tsconfig.json', { stdio: 'inherit' });
} catch (e) {
console.error('status' in e ? e.toString() : e);
}
Expand Down
6 changes: 3 additions & 3 deletions src/FileSystemAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ export class FileSystemAccessFS extends Async(FileSystem) {
throw ApiError.OnPath(ErrorCode.ENOENT, path);
}
if (handle instanceof FileSystemDirectoryHandle) {
return new Stats(FileType.DIRECTORY, 4096);
return new Stats({ mode: 0o777 | FileType.DIRECTORY, size: 4096 });
}
if (handle instanceof FileSystemFileHandle) {
const { lastModified, size } = await handle.getFile();
return new Stats(FileType.FILE, size, null, Date.now(), lastModified);
return new Stats({ mode: 0o777 | FileType.FILE, size, mtimeMs: lastModified });
}
}

Expand All @@ -149,7 +149,7 @@ export class FileSystemAccessFS extends Async(FileSystem) {
if (handle instanceof FileSystemFileHandle) {
const file = await handle.getFile();
const data = new Uint8Array(await file.arrayBuffer());
const stats = new Stats(FileType.FILE, file.size, null, Date.now(), file.lastModified);
const stats = new Stats({ mode: 0o777 | FileType.FILE, size: file.size, mtimeMs: file.lastModified });
return new FileSystemAccessFile(this, path, flag, stats, data);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/IndexedDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export const IndexedDB: Backend = {
} catch (e) {
return false;
}
return true;
},

create({ cacheSize = 100, storeName = 'browserfs', idbFactory = globalThis.indexedDB }: IndexedDBOptions) {
Expand Down

1 comment on commit a9c40c6

@james-pre
Copy link
Member Author

@james-pre james-pre commented on a9c40c6 Mar 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanchezcarlosjr,

This fixes the issue you resolved in sanchezcarlosjr/BrowserFS 9d56332

You may want to consider using the updated fork, ZenFS (ZenFS DOM)

See https://github.com/browser-fs/NOTICE

Please sign in to comment.