28 this FetchOptions fetchOptions,
31 CredentialsHandler credentialsHandler,
32 CancellationToken cancellationToken)
34 ArgumentNullException.ThrowIfNull(fetchOptions);
35 ArgumentNullException.ThrowIfNull(logger);
37 fetchOptions.OnProgress = _ => !cancellationToken.IsCancellationRequested;
38 fetchOptions.OnTransferProgress = transferProgress =>
40 if (progressReporter !=
null)
42 var percentage = ((double)transferProgress.IndexedObjects + transferProgress.ReceivedObjects) / (transferProgress.TotalObjects * 2);
46 return !cancellationToken.IsCancellationRequested;
48 fetchOptions.OnUpdateTips = (_, _, _) => !cancellationToken.IsCancellationRequested;
49 fetchOptions.CredentialsProvider = credentialsHandler;
50 fetchOptions.RepositoryOperationStarting = _ => !cancellationToken.IsCancellationRequested;
69 var totalObjectsToProcess = transferProgress.TotalObjects * 2;
70 var processedObjects = transferProgress.IndexedObjects + transferProgress.ReceivedObjects;
71 if (totalObjectsToProcess < processedObjects || totalObjectsToProcess == 0)
75 percentage = (double)processedObjects / totalObjectsToProcess;
80 if (percentage ==
null)
82 "Bad transfer progress values (Please tell Cyberboss)! Indexed: {indexed}, Received: {received}, Total: {total}",
83 transferProgress.IndexedObjects,
84 transferProgress.ReceivedObjects,
85 transferProgress.TotalObjects);
87 progressReporter?.ReportProgress(percentage);
88 return !cancellationToken.IsCancellationRequested;