@Nullable
  private static FileLock tryLockDirectory(@NotNull Path directory) {
    try {
      Files.createDirectories(directory);

      Path lockFile = directory.resolve(LOCK_FILE_NAME);

      //noinspection resource
      FileChannel fc = FileChannel.open(lockFile, StandardOpenOption.CREATE, StandardOpenOption.APPEND, StandardOpenOption.WRITE);
      return fc.tryLock();
    }
    catch (IOException ignore) {
      return null;
    }
  }
@Nullable
  private static FileLock tryLockDirectory(@NotNull Path directory)