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

Commit 9f54daf

Browse files
author
Lilian ARAGO
committed
Fix progression display
1 parent 58b5ade commit 9f54daf

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

TCC.Lib/TarCompressCrypt.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ public async Task<OperationSummary> CompressAsync(CompressOption option)
9090

9191
private async Task<OperationCompressionBlock> UploadBlockInternal(IEnumerable<IRemoteStorage> uploaders, CompressOption option, OperationCompressionBlock block, CancellationToken token)
9292
{
93-
foreach(var uploader in uploaders)
93+
int count = Interlocked.Increment(ref _uploadCounter);
94+
string progress = $"{count}/{_totalCounter}";
95+
96+
foreach (var uploader in uploaders)
9497
{
9598
if (uploader is NoneRemoteStorage)
9699
{
@@ -129,15 +132,15 @@ private async Task<OperationCompressionBlock> UploadBlockInternal(IEnumerable<IR
129132

130133
if (!hasError)
131134
{
132-
_logger.LogInformation($"{progress} Uploaded \"{file.Name}\" in {sw.Elapsed.HumanizedTimeSpan()} at {speed.HumanizedBandwidth()} ");
135+
_logger.LogInformation($"[{uploader.GetMode()}] {progress} Uploaded \"{file.Name}\" in {sw.Elapsed.HumanizedTimeSpan()} at {speed.HumanizedBandwidth()} ");
133136
}
134137
else
135138
{
136139
if (ctx == null && option.RetryPeriodInSeconds.HasValue)
137140
{
138141
ctx = new RetryContext(option.RetryPeriodInSeconds.Value);
139142
}
140-
_logger.LogError($"{progress} Uploaded {file.Name} with errors. {result.ErrorMessage}");
143+
_logger.LogError($"[{uploader.GetMode()}] {progress} Uploaded {file.Name} with errors. {result.ErrorMessage}");
141144
}
142145
}
143146
catch (Exception e)
@@ -147,14 +150,14 @@ private async Task<OperationCompressionBlock> UploadBlockInternal(IEnumerable<IR
147150
{
148151
ctx = new RetryContext(option.RetryPeriodInSeconds.Value);
149152
}
150-
_logger.LogCritical(e, $"{progress} Error uploading {name}");
153+
_logger.LogCritical(e, $"[{uploader.GetMode()}] {progress} Error uploading {name}");
151154
}
152155

153156
if (hasError)
154157
{
155158
if (ctx != null && await ctx.WaitForNextRetry())
156159
{
157-
_logger.LogWarning($"{progress} Retrying uploading {name}, attempt #{ctx.Retries}");
160+
_logger.LogWarning($"[{uploader.GetMode()}] {progress} Retrying uploading {name}, attempt #{ctx.Retries}");
158161
}
159162
else
160163
{

0 commit comments

Comments
 (0)