private static @NotNull Promise<VirtualFile> createDownloadedCallback(final @NotNull RemoteFileInfo remoteFileInfo) {
    final AsyncPromise<VirtualFile> promise = new AsyncPromise<>();
    remoteFileInfo.addDownloadingListener(new FileDownloadingAdapter() {
      @Override
      public void fileDownloaded(@NotNull VirtualFile localFile) {
        try {
          remoteFileInfo.removeDownloadingListener(this);
        }
        finally {
          promise.setResult(localFile);
        }
      }

      @Override
      public void errorOccurred(@NotNull String errorMessage) {
        try {
          remoteFileInfo.removeDownloadingListener(this);
        }
        finally {
          promise.setError(errorMessage);
        }
      }

      @Override
      public void downloadingCancelled() {
        try {
          remoteFileInfo.removeDownloadingListener(this);
        }
        finally {
          promise.setError("Cancelled");
        }
      }
    });
    return promise;
  }
private static @NotNull Promise<VirtualFile> createDownloadedCallback(final @NotNull RemoteFileInfo remoteFileInfo)