downloadPath function

Future<TransferResult> downloadPath({
  1. required ClientRuntime client,
  2. required String nodeId,
  3. required String remotePath,
  4. required String localDest,
  5. bool destIsDir = false,
  6. int gzipLevel = kDefaultGzipLevel,
  7. void onProgress(
    1. TransferProgress
    )?,
  8. Future<bool> confirm(
    1. TransferPreflight
    )?,
})

Downloads remotePath from nodeId to the local localDest (a directory to write into, or an explicit target path — see FileTransferEngine.runReceiver; destIsDir forces directory mode), resuming any partial files and verifying each file's SHA-256.

Implementation

Future<TransferResult> downloadPath({
  required ClientRuntime client,
  required String nodeId,
  required String remotePath,
  required String localDest,
  bool destIsDir = false,
  int gzipLevel = kDefaultGzipLevel,
  void Function(TransferProgress)? onProgress,
  Future<bool> Function(TransferPreflight)? confirm,
}) async {
  final session = await _openTransfer(
    client,
    nodeId: nodeId,
    direction: 'download',
    remotePath: remotePath,
    gzipLevel: gzipLevel,
  );
  try {
    final engine = FileTransferEngine(ClientTransferLink(session));
    final result = await engine.runReceiver(
      dest: localDest,
      destIsDir: destIsDir,
      onProgress: onProgress,
      confirm: confirm,
    );
    await session.exitCode;
    return result;
  } finally {
    await session.close();
  }
}