Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
Fix progression display
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilian ARAGO committed Feb 15, 2023
1 parent 58b5ade commit f6d2eee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions TCC.Lib/TarCompressCrypt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ public async Task<OperationSummary> CompressAsync(CompressOption option)

private async Task<OperationCompressionBlock> UploadBlockInternal(IEnumerable<IRemoteStorage> uploaders, CompressOption option, OperationCompressionBlock block, CancellationToken token)
{
foreach(var uploader in uploaders)
int count = Interlocked.Increment(ref _uploadCounter);
string progress = $"{count}/{_totalCounter}";

foreach (var uploader in uploaders)
{
if (uploader is NoneRemoteStorage)
{
continue;
}

int count = Interlocked.Increment(ref _uploadCounter);
string progress = $"{count}/{_totalCounter}";

var file = block.CompressionBlock.DestinationArchiveFileInfo;
var name = file.Name;
RetryContext ctx = null;
Expand Down Expand Up @@ -129,15 +129,15 @@ private async Task<OperationCompressionBlock> UploadBlockInternal(IEnumerable<IR

if (!hasError)
{
_logger.LogInformation($"{progress} Uploaded \"{file.Name}\" in {sw.Elapsed.HumanizedTimeSpan()} at {speed.HumanizedBandwidth()} ");
_logger.LogInformation($"[{uploader.GetMode()}] {progress} Uploaded \"{file.Name}\" in {sw.Elapsed.HumanizedTimeSpan()} at {speed.HumanizedBandwidth()} ");
}
else
{
if (ctx == null && option.RetryPeriodInSeconds.HasValue)
{
ctx = new RetryContext(option.RetryPeriodInSeconds.Value);
}
_logger.LogError($"{progress} Uploaded {file.Name} with errors. {result.ErrorMessage}");
_logger.LogError($"[{uploader.GetMode()}] {progress} Uploaded {file.Name} with errors. {result.ErrorMessage}");
}
}
catch (Exception e)
Expand All @@ -147,14 +147,14 @@ private async Task<OperationCompressionBlock> UploadBlockInternal(IEnumerable<IR
{
ctx = new RetryContext(option.RetryPeriodInSeconds.Value);
}
_logger.LogCritical(e, $"{progress} Error uploading {name}");
_logger.LogCritical(e, $"[{uploader.GetMode()}] {progress} Error uploading {name}");
}

if (hasError)
{
if (ctx != null && await ctx.WaitForNextRetry())
{
_logger.LogWarning($"{progress} Retrying uploading {name}, attempt #{ctx.Retries}");
_logger.LogWarning($"[{uploader.GetMode()}] {progress} Retrying uploading {name}, attempt #{ctx.Retries}");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion TCC.Tests/Upload/BlobStorageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task GoogleUploadTest()

Assert.True(ok.IsSuccess);

var gs = uploader as GoogleRemoteStorage;
var gs = uploader.First() as GoogleRemoteStorage;

await gs.Storage.DeleteObjectAsync(gs.BucketName, ok.RemoteFilePath);
}
Expand Down

0 comments on commit f6d2eee

Please sign in to comment.