mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-07-28 04:08:05 +00:00
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:
+1
-1
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user