-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overlay index fetch issue #82
Changes from all commits
a1e536b
6a876c9
d2459a3
9604ac2
464fce8
d44fed4
82087c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
/** | ||
* The current locks | ||
*/ | ||
private locks: Map<string, MutexLock> = new Map(); | ||
private locks: Map<string, [MutexLock]> = new Map(); | ||
|
||
protected addLock(path: string): MutexLock { | ||
const lock: MutexLock = { | ||
|
@@ -36,7 +36,11 @@ | |
this.unlock(path); | ||
}, | ||
}; | ||
this.locks.set(path, lock); | ||
if (this.locks.has(path)) { | ||
this.locks.get(path)!.push(lock); | ||
} else { | ||
this.locks.set(path, [lock]); | ||
} | ||
return lock; | ||
} | ||
|
||
|
@@ -48,7 +52,8 @@ | |
public async lock(path: string): Promise<MutexLock> { | ||
if (this.locks.has(path)) { | ||
// Non-null assertion: we already checked locks has path | ||
await this.locks.get(path)!.promise; | ||
james-pre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const promise = this.locks.get(path)!.at(-1); | ||
await promise; | ||
Check failure on line 56 in src/backends/locked.ts GitHub Actions / Ubuntu / CI
Check failure on line 56 in src/backends/locked.ts GitHub Actions / MacOS / CI
|
||
} | ||
|
||
return this.addLock(path); | ||
|
@@ -84,8 +89,8 @@ | |
} | ||
|
||
// Non-null assertion: we already checked locks has path | ||
this.locks.get(path)!.resolve(); | ||
this.locks.delete(path); | ||
const res = this.locks.get(path)!.shift(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, please inline: |
||
res!.resolve(); | ||
return true; | ||
} | ||
|
||
|
@@ -94,7 +99,7 @@ | |
* @internal | ||
*/ | ||
public isLocked(path: string): boolean { | ||
return this.locks.has(path); | ||
return this.locks.has(path) && this.locks.get(path)!.length > 0; | ||
james-pre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
public async ready(): Promise<void> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a tuple with a single
MutexLock
. Do you mean an array,MutexLock[]
?