merge: client server mode (sync engine, Server screen sync table and conflicts, Library sync glyphs, render transfers)
Keeps the render node host from the processing branch and disposes the sync host after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
56 files changed
+6777
-25
No files matched your search
@@ -28,8 +28,9 @@ namespace Titano.App.Infrastructure;
|
||||
/// Composition root of local mode (BRIEF §4.4): the SQLite index under the data folder (migrated on open), the
|
||||
/// archive engine (WIC first, then managed decoders), the analysis and render engine (the same decoders; Media
|
||||
/// Foundation, then managed encoders), the one <see cref="JobEngine"/> of this PC with the handlers of
|
||||
/// <see cref="CreateJobHandlers"/>, thumbnails, the server session, the render node, the encoder inventory and the
|
||||
/// update check. Started after the window shows, stopped when the app exits. The last archive is reopened at start and
|
||||
/// <see cref="CreateJobHandlers"/>, thumbnails, the server session, the render node, the encoder inventory, the
|
||||
/// update check and the sync with the signed-in server (<see cref="SyncHost"/>). Started after the window shows,
|
||||
/// stopped when the app exits. The last archive is reopened at start and
|
||||
/// rescanned every <see cref="ScanInterval"/> (BRIEF §7: polling, no file-system watchers). The render node runs while
|
||||
/// the user offers this PC (<see cref="AppSettings.RenderNodeOptIn"/>) and a server session is open (never in capture
|
||||
/// mode). Renders and the render node use hardware encoders as Settings › Rendering allows
|
||||
@@ -60,6 +61,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
Dialogs = dialogs;
|
||||
_renderNode = new RenderNodeHost(StartRenderNode);
|
||||
ArchiveSetup = new EngineArchiveSetup(this);
|
||||
Sync = new SyncHost(this);
|
||||
Server = new ServerSession(settings, saveSettings, new TitanoServerApiFactory(), new DpapiTokenProtector());
|
||||
Encoders = new MediaFoundationInventory();
|
||||
CheckForUpdateAsync = ct => UpdateCheck.FetchAsync(Http.Value, ProductLinks.LatestReleaseApi, VersionText, ct);
|
||||
@@ -92,9 +94,13 @@ public sealed class AppServices : IAsyncDisposable
|
||||
_server = value;
|
||||
_server.PropertyChanged += OnServerChanged;
|
||||
UpdateRenderNode();
|
||||
Sync.Update();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Sync with the signed-in server: engine, job connection, background comparison.</summary>
|
||||
public SyncHost Sync { get; }
|
||||
|
||||
public IEncoderInventory Encoders { get; set; }
|
||||
|
||||
/// <summary>Latest public release (GitHub Releases API of the releases repository, BRIEF §18).</summary>
|
||||
@@ -125,7 +131,10 @@ public sealed class AppServices : IAsyncDisposable
|
||||
/// <summary>The job handlers of this PC's engine — the single registration list; a kind without a handler stays
|
||||
/// queued (it is never claimed here).</summary>
|
||||
public static IReadOnlyList<IJobHandler> CreateJobHandlers(AppServices services) =>
|
||||
[.. services.Archives?.CreateJobHandlers() ?? [], .. services.Processing?.CreateJobHandlers() ?? []];
|
||||
[
|
||||
.. services.Archives?.CreateJobHandlers() ?? [], .. services.Processing?.CreateJobHandlers() ?? [],
|
||||
.. services.Sync.Service?.CreateJobHandlers(services.Sync) ?? [],
|
||||
];
|
||||
|
||||
/// <summary>Queues a scan of <paramref name="archive"/> unless one is already waiting or running.</summary>
|
||||
public async Task QueueScanAsync(Archive archive, bool full, CancellationToken ct = default)
|
||||
@@ -199,6 +208,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
_stopping.Dispose();
|
||||
_server.PropertyChanged -= OnServerChanged;
|
||||
await _renderNode.DisposeAsync().ConfigureAwait(false);
|
||||
await Sync.DisposeAsync().ConfigureAwait(false);
|
||||
(Jobs as IDisposable)?.Dispose();
|
||||
if (Engine is not null) await Engine.DisposeAsync().ConfigureAwait(false);
|
||||
Thumbnails?.Dispose();
|
||||
@@ -235,6 +245,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
var archive = new ArchiveServiceOptions { Decoder = DecoderFactory.CreateClient(new WicDecoderProvider()) };
|
||||
Archives = new ArchiveService(database, archive);
|
||||
Processing = new ProcessingService(database, ProcessingOptions(archive));
|
||||
Sync.Open(database, Archives, archive);
|
||||
var handlers = CreateJobHandlers(this);
|
||||
var kinds = handlers.Select(h => h.Kind).Distinct().ToArray();
|
||||
Engine = new JobEngine(database, handlers, new JobEngineOptions { WorkerId = WorkerId, Kinds = kinds });
|
||||
@@ -244,6 +255,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
Jobs = new EngineJobQueue(database, Engine, started);
|
||||
Log.Info("jobs", started ? $"Job engine started with {Engine.Options.Workers} worker(s) for {string.Join(", ", kinds)}" : "No job handlers registered; jobs stay queued");
|
||||
UpdateRenderNode();
|
||||
Sync.Update();
|
||||
}
|
||||
|
||||
/// <summary>Media Foundation (hardware first, software H.264; hardware as Settings › Rendering allows) then managed
|
||||
@@ -263,7 +275,11 @@ public sealed class AppServices : IAsyncDisposable
|
||||
},
|
||||
};
|
||||
|
||||
private void OnServerChanged(object? sender, PropertyChangedEventArgs e) => UpdateRenderNode();
|
||||
private void OnServerChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
UpdateRenderNode();
|
||||
Sync.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The render node of <paramref name="session"/>: this PC's encoders (Media Foundation, then managed), downloads and
|
||||
|
||||
Reference in new issue
Block a user