mirror of
https://github.com/ProtonDriveApps/sdk.git
synced 2026-05-15 09:50:35 +00:00
Fix upload failing to resume when blocks were uploaded out of order
This commit is contained in:
@@ -86,7 +86,10 @@ internal sealed partial class TransferQueue(int maxDegreeOfParallelism, ILogger
|
||||
return queuePosition;
|
||||
}
|
||||
|
||||
public void SetFileTotalBlockCount(long queueToken, int total)
|
||||
/// <summary>
|
||||
/// Increases the total and remaining block counts for a file if the given total is greater than the current one.
|
||||
/// </summary>
|
||||
public void ApplyFileMinimumTotalBlockCount(long queueToken, int total)
|
||||
{
|
||||
lock (_fileBlocksLock)
|
||||
{
|
||||
@@ -95,16 +98,14 @@ internal sealed partial class TransferQueue(int maxDegreeOfParallelism, ILogger
|
||||
: throw new InvalidOperationException($"Queue token {queueToken} not found in transfer queue.");
|
||||
|
||||
var delta = total - currentTotal;
|
||||
if (delta <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (delta > 0)
|
||||
{
|
||||
FileQueueSemaphore.DecreaseCount(delta);
|
||||
LogDecreasedFileQueueSemaphoreCount(delta, FileQueueSemaphore.CurrentCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveBlocksFromFileQueue(-delta);
|
||||
}
|
||||
FileQueueSemaphore.DecreaseCount(delta);
|
||||
|
||||
LogDecreasedFileQueueSemaphoreCount(delta, FileQueueSemaphore.CurrentCount);
|
||||
|
||||
_fileBlocks[queueToken] = (currentRemaining + delta, total);
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ internal sealed partial class RevisionWriter
|
||||
|
||||
currentBlockNumber = newBlockNumber;
|
||||
|
||||
_client.UploadQueue.SetFileTotalBlockCount(_queueToken, currentBlockNumber.Value + expectedThumbnailBlockCount);
|
||||
_client.UploadQueue.ApplyFileMinimumTotalBlockCount(_queueToken, currentBlockNumber.Value + expectedThumbnailBlockCount);
|
||||
|
||||
// ReSharper disable once PossiblyMistakenUseOfCancellationToken
|
||||
await WaitForBlockUploaderAsync(uploadTasks, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user