in src/commands/azCopy/azCopyTransfer.ts [85:119]
async function startAndWaitForTransfer(
context: IActionContext,
location: ITransferLocation,
options: ICopyOptions,
transferProgress: TransferProgress,
notificationProgress?: NotificationProgress,
cancellationToken?: CancellationToken
): Promise<IJobInfo> {
const copyClient: AzCopyClient = new AzCopyClient();
const jobId: string = await copyClient.copy(location.src, location.dst, options);
// Directory transfers always have `useWildCard` set
const displayWorkAsTotalTransfers: boolean = location.src.useWildCard;
let status: TransferStatus | undefined;
let finishedWork: number;
let totalWork: number | undefined;
while (!status || status.StatusType !== 'EndOfJob') {
throwIfCanceled(cancellationToken, context.telemetry.properties, 'startAndWaitForTransfer');
status = (await copyClient.getJobInfo(jobId)).latestStatus;
totalWork = (displayWorkAsTotalTransfers ? status?.TotalTransfers : status?.TotalBytesEnumerated) || undefined;
finishedWork = (displayWorkAsTotalTransfers ? status?.TransfersCompleted : status?.BytesOverWire) || 0;
if (totalWork) {
// Only report progress if we have `totalWork`
transferProgress.reportToOutputWindow(finishedWork, totalWork);
if (notificationProgress) {
transferProgress.reportToNotification(finishedWork, totalWork, notificationProgress);
}
}
await delay(1000);
}
return await copyClient.getJobInfo(jobId);
}