tryAcquire static method

ProjectLock? tryAcquire(
  1. JustProject project
)

Takes the lock on project, or returns null when another change holds it. Throws a FileSystemException when the lock can't be made at all (a read-only folder, a path too long).

Implementation

static ProjectLock? tryAcquire(JustProject project) {
  final file = project.file(path);
  changesFolder(project);
  final lock = FileLock.tryAcquire(file, what: 'the project lock');
  if (lock == null) return null;
  if (_legacyHeld(project)) {
    // An older tool is changing the project: it goes first.
    lock.release();
    return null;
  }
  return ProjectLock._(lock);
}