All files / src/fsa FileLockManager.ts

100% Statements 9/9
100% Branches 3/3
100% Functions 5/5
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2468x 577x     103x 1x   102x 102x       82x       168x       2x      
export class FileLockManager {
  private locks: Map<string, boolean> = new Map();
 
  public acquireLock(path: string): boolean {
    if (this.locks.get(path)) {
      return false;
    }
    this.locks.set(path, true);
    return true;
  }
 
  public releaseLock(path: string): void {
    this.locks.delete(path);
  }
 
  public isLocked(path: string): boolean {
    return this.locks.get(path) ?? false;
  }
 
  public clear(): void {
    this.locks.clear();
  }
}