feat(uploader): upload engine with queue retries and verified-only source deletion

Two parallel files: hash, resumable upload through a transport, then
verified or already-on-server. Failed items retry after 30 s up to 3
times on top of the client's transient retries; an unreachable server
requeues without spending a retry. A new-sequence batch creates its
sequence once. "Delete after upload" removes only files the server
confirmed and that still match the hashed size and write time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 10:27:24 +00:00
1 parent 62c7b0d956
commit 2a74c12fd1
4 files changed
+676

No files matched your search

@@ -0,0 +1,41 @@
using System.Collections.Concurrent;
namespace Titano.App.Tests.Uploader;
/// <summary>Runs async test code on one thread, as the UI dispatcher does for the upload engine.</summary>
internal sealed class SingleThreadedContext : SynchronizationContext
{
private readonly BlockingCollection<(SendOrPostCallback Callback, object? State)> _queue = [];
public override void Post(SendOrPostCallback d, object? state)
{
try
{
_queue.Add((d, state));
}
catch (InvalidOperationException)
{
// Late progress reports after the test body finished are dropped.
}
}
public override void Send(SendOrPostCallback d, object? state) => throw new NotSupportedException();
public static void Run(Func<Task> body)
{
var previous = Current;
var context = new SingleThreadedContext();
SetSynchronizationContext(context);
try
{
var task = body();
task.ContinueWith(_ => context._queue.CompleteAdding(), TaskScheduler.Default);
foreach (var (callback, state) in context._queue.GetConsumingEnumerable()) callback(state);
task.GetAwaiter().GetResult();
}
finally
{
SetSynchronizationContext(previous);
}
}
}