TransferStatusProvider
namespace Relativity.Transfer
{
internal sealed class TransferStatusProvider
{
private readonly ClientConfiguration configuration;
private bool TreatMissingFilesAsWarnings => configuration.FileNotFoundErrorsDisabled;
public TransferStatusProvider(ClientConfiguration configuration)
{
this.configuration = configuration;
}
public TransferStatus GetTransferStatus(ITransferStatistics statistics)
{
if (statistics.TotalFatalErrors > 0 || (!configuration.PermissionErrorsRetry && statistics.TotalFilePermissionsErrors > 0) || (!configuration.BadPathErrorsRetry && statistics.TotalBadPathErrors > 0))
return TransferStatus.Fatal;
if (statistics.TotalFilesNotFound > 0 && TreatMissingFilesAsWarnings && statistics.TotalFailedFiles == 0 && statistics.TotalFilePermissionsErrors == 0 && statistics.TotalBadPathErrors == 0 && statistics.TotalFilesIdentifiedAsMalware == 0)
return TransferStatus.Successful;
if (statistics.TotalFilesIdentifiedAsMalware > 0 && statistics.TotalFailedFiles == 0)
return TransferStatus.CompletedWithWarnings;
if (statistics.JobError || (!TreatMissingFilesAsWarnings && statistics.TotalFilesNotFound > 0) || statistics.TotalFailedFiles > 0 || (!configuration.TransferEmptyDirectories && statistics.TotalTransferredFiles == 0) || (configuration.PermissionErrorsRetry && statistics.TotalFilePermissionsErrors > 0) || (configuration.BadPathErrorsRetry && statistics.TotalBadPathErrors > 0))
return TransferStatus.Failed;
return TransferStatus.Successful;
}
}
}