fileStorage: implement file locks

This breaks down reading and writing into low-level and high level sagas.

Opening now takes a lock on the file so that it can only have one writer
or have multiple readers. The low-level read and write sagas use the
file descriptor to determine if the file is still open before actually
performing the action.

Since we are using the web locks api, these locks should work across
browser tabs/windows.

The high-level read/write sagas perform the low-level open, read/write,
close operations in a single call.

The high-level delete and rename sagas are also updated to take locks
on the files while performing the respective operations and will fail
if the file is already being used somewhere else.
This commit is contained in:
David Lechner
2022-04-04 15:24:08 -05:00
parent 7ef08122e8
commit b9dbaaa5cb
12 changed files with 1278 additions and 420 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ export class AsyncSaga {
// if there are no dispatches queued, then queue the taker to be
// completed later
return new Promise((resolve, reject) => {
const timeout = setTimeout(reject, 500, new Error('timed out'));
const timeout = setTimeout(reject, 1000, new Error('timed out'));
this.takers.push({
put: (a: AnyAction): void => {