uploadPath function
Future<TransferResult>
uploadPath({})
Uploads the local localPath to remoteDir on nodeId, resuming any
partial files; the node verifies each file's SHA-256 and reports failure via
the session exit code.
Implementation
Future<TransferResult> uploadPath({
required ClientRuntime client,
required String nodeId,
required String localPath,
required String remoteDir,
int gzipLevel = kDefaultGzipLevel,
void Function(TransferProgress)? onProgress,
Future<bool> Function(TransferPreflight)? confirm,
}) async {
final manifest = buildManifest(localPath);
final session = await _openTransfer(
client,
nodeId: nodeId,
direction: 'upload',
remotePath: remoteDir,
gzipLevel: gzipLevel,
);
try {
final engine = FileTransferEngine(ClientTransferLink(session));
await engine.runSender(
baseDir: manifest.baseDir,
entries: manifest.entries,
single: manifest.single,
gzipLevel: gzipLevel,
onProgress: onProgress,
confirm: confirm,
);
final code = await session.exitCode;
if (code == 0) {
return TransferResult(
verified: [for (final e in manifest.entries) e.path],
failures: const {},
);
}
return TransferResult(
verified: const [],
failures: {
for (final e in manifest.entries) e.path: 'node reported a failure',
},
);
} finally {
await session.close();
}
}