fixes uploads cancelling early

This commit is contained in:
rootdarkarchon
2022-11-03 20:45:44 +01:00
parent 56dd3c2f65
commit 605c1d3774
2 changed files with 3 additions and 12 deletions

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<Authors></Authors>
<Company></Company>
<Version>0.5.7</Version>
<Version>0.5.8</Version>
<Description></Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>

View File

@@ -239,22 +239,13 @@ public partial class ApiController
Logger.Debug($"Compressed {totalSize} to {compressedSize} ({(compressedSize / (double)totalSize):P2})");
Logger.Debug("Upload tasks complete, waiting for server to confirm");
var anyUploadsOpen = await FilesIsUploadFinished().ConfigureAwait(false);
Logger.Debug("Uploads open: " + anyUploadsOpen);
double timeWaited = 0;
Logger.Debug("Uploads open: " + CurrentUploads.Any(c => c.IsInTransfer));
const double waitStep = 1.0d;
while (anyUploadsOpen && !uploadToken.IsCancellationRequested && timeWaited < 5)
while (CurrentUploads.Any(c => c.IsInTransfer) && !uploadToken.IsCancellationRequested)
{
anyUploadsOpen = await FilesIsUploadFinished().ConfigureAwait(false);
timeWaited += waitStep;
await Task.Delay(TimeSpan.FromSeconds(waitStep), uploadToken).ConfigureAwait(false);
Logger.Debug("Waiting for uploads to finish");
}
if(timeWaited > waitStep)
{
await FilesAbortUpload().ConfigureAwait(false);
}
}
foreach (var item in unverifiedUploadHashes)