feat: owner review 2 phase 5c: originals, local render, clean-up and the workspace settings (#18)
CI / Build and test (push) Successful in 9m26s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 8s
Release / Build, test and publish (push) Successful in 14m31s
CI / PostgreSQL 16 integration (push) Successful in 9m53s
CI / PostgreSQL 17 integration (push) Successful in 9m22s
CI / Docker image (push) Successful in 44s
Release / Server image (push) Successful in 1m36s
CI / Build and test (push) Successful in 9m26s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 8s
Release / Build, test and publish (push) Successful in 14m31s
CI / PostgreSQL 16 integration (push) Successful in 9m53s
CI / PostgreSQL 17 integration (push) Successful in 9m22s
CI / Docker image (push) Successful in 44s
Release / Server image (push) Successful in 1m36s
Originals in the workspace, local render and send home with provenance, the workspace clean-up, size limit and trash, moving the workspace folder, and the complete Settings › Workspace page (owner review 2, R8, phase 5c). One adversarial review round (35 findings, 32 fixed), a copy-cancel race fixed, 184 strings in all 38 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #18.
This commit is contained in:
1 parent
81c303f484
commit
db389a54f2
364 files changed
+17417
-595
No files matched your search
@@ -327,6 +327,12 @@
|
||||
ToolTip="{l:Loc Tooltips.Editor.Export.History}" Margin="6,0,0,0" Visibility="{Binding CanOpenHistory, Converter={StaticResource BoolToVisibility}}" />
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Link}" Content="{l:Loc Editor.Export.Reveal}" Command="{Binding RevealLastCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Render.Reveal}" Margin="6,0,0,0" Visibility="{Binding CanReveal, Converter={StaticResource BoolToVisibility}}" />
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Link}" Content="{l:Loc Editor.Render.SendAgain}" Command="{Binding SendAgainCommand}"
|
||||
ToolTip="{Binding SendAgainToolTip}" ToolTipService.ShowOnDisabled="True" Margin="6,0,0,0"
|
||||
Visibility="{Binding HasUnsent, Converter={StaticResource BoolToVisibility}}" />
|
||||
<TextBlock DockPanel.Dock="Right" Text="{l:Loc Editor.Render.NotSent}" Style="{StaticResource Text.Faint}" FontSize="{StaticResource Size.Chip}"
|
||||
VerticalAlignment="Center" Margin="6,0,0,0" ToolTip="{Binding UnsentToolTip}"
|
||||
Visibility="{Binding HasUnsent, Converter={StaticResource BoolToVisibility}}" />
|
||||
<TextBlock Text="{Binding HistoryText}" Style="{StaticResource Text.Faint}" FontSize="{StaticResource Size.Chip}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center"
|
||||
ToolTip="{Binding HistoryText}" />
|
||||
</DockPanel>
|
||||
|
||||
@@ -241,8 +241,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
/// <summary>The Export "Sync" option: available, or why not.</summary>
|
||||
public ExportSyncGate SyncGate { get => _syncGate; private set => Set(ref _syncGate, value); }
|
||||
|
||||
/// <summary>The server job the header shows (<see cref="SequenceJobs.Shown"/>).</summary>
|
||||
private Job? ServerJob => IsRemote ? _jobs.Shown : null;
|
||||
/// <summary>The server job the header shows (<see cref="SequenceJobs.ShownAtHome"/>): never a workspace project's render on this PC or its send.</summary>
|
||||
private Job? ServerJob => IsRemote ? _jobs.ShownAtHome : null;
|
||||
|
||||
/// <summary>
|
||||
/// "3,600 frames · Canon EOS R5 · 2 s interval · 2 h 00 m · 3 warnings"; on the Export tab what the video will be:
|
||||
@@ -634,7 +634,9 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
var export = batch ? RenderExport : RenderExport with { Batch = [] };
|
||||
var requests = Session.RenderRequests(export);
|
||||
foreach (var request in requests) await Session.SubmitAsync(request with { Priority = priority });
|
||||
if (IsRemote) Shell.Notify(Loc.L("Editor.Render.QueuedServer", ServerName), requests[0].Label);
|
||||
if (Session.Source is IProjectRenders { RendersLocally: true })
|
||||
Shell.Notify(Loc.L("Editor.Render.QueuedLocal"), requests[0].Label, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
|
||||
else if (IsRemote) Shell.Notify(Loc.L("Editor.Render.QueuedServer", ServerName), requests[0].Label);
|
||||
else Shell.Notify(Loc.L("Editor.Render.Queued"), requests[0].Label, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
|
||||
}
|
||||
|
||||
@@ -957,7 +959,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
private void RefreshSteps()
|
||||
{
|
||||
if (_disposed) return;
|
||||
var facts = new PathFacts(Session.Content, Session.Advice, Session.Project, _jobs.Active(JobKind.DeepAnalyse), _jobs.Active(JobKind.Render),
|
||||
var facts = new PathFacts(Session.Content, Session.Advice, Session.Project, _jobs.Active(JobKind.DeepAnalyse), _jobs.Active(JobKind.Render) ?? _jobs.Active(JobKind.WorkspaceRender),
|
||||
_planned ? RenderBlockedReason : null, _rendered.Matches(Session.Project));
|
||||
foreach (var tab in Tabs) tab.SetStep(EditPath.Of(tab.Key, facts));
|
||||
Analysis.OnStepChanged();
|
||||
@@ -1174,7 +1176,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
if (_disposed)
|
||||
{
|
||||
// Closed after the Jobs screen left this render's end to it (FollowsRender): said without a read.
|
||||
if (job is { Kind: JobKind.Render, State: JobState.Done } && _jobs.IsActive(job.Id) && Shell.Jobs.ClaimRenderToast(job.Id))
|
||||
if (job is { State: JobState.Done } && IsRender(job.Kind) && _jobs.IsActive(job.Id) && Shell.Jobs.ClaimRenderToast(job.Id))
|
||||
AnnounceRender(job, read: false);
|
||||
return;
|
||||
}
|
||||
@@ -1186,13 +1188,19 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
if (!wasActive) return;
|
||||
if (job is { Kind: JobKind.DeepAnalyse, State: JobState.Done }) ClearVisited();
|
||||
// A render this editor followed to its end is said here, with its output, unless the Jobs screen said it first.
|
||||
if (job.State == JobState.Done) _ = ReloadAsync(job.Kind == JobKind.Render && Shell.Jobs.ClaimRenderToast(job.Id) ? job : null);
|
||||
if (job.State == JobState.Done) _ = ReloadAsync(IsRender(job.Kind) && Shell.Jobs.ClaimRenderToast(job.Id) ? job : null);
|
||||
// A local render's send home (phase 5c): said once, here or on the Jobs screen.
|
||||
if (job is { Kind: JobKind.WorkspaceSend, State: JobState.Done } && Shell.Jobs.ClaimRenderToast(job.Id)) Shell.Notify(Loc.L("Editor.Render.SentHome"), Title);
|
||||
// An analysis may have written its Auto values into the library's settings (Main): the project takes them or says so.
|
||||
if (job.State == JobState.Done && _project is { } project) _ = project.JobEndedAsync(job);
|
||||
else if (IsRemote && job.State is JobState.Failed or JobState.Cancelled) ReportServerJobEnded(job);
|
||||
else if (IsRemote && job.Kind is not (JobKind.WorkspaceRender or JobKind.WorkspaceSend) && job.State is JobState.Failed or JobState.Cancelled)
|
||||
ReportServerJobEnded(job);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>A render of the sequence: at its home, or on this PC from a workspace project's originals (phase 5c).</summary>
|
||||
private static bool IsRender(JobKind kind) => kind is JobKind.Render or JobKind.WorkspaceRender;
|
||||
|
||||
/// <summary>
|
||||
/// The frames of the server sequence changed while it is open, or a workspace project's sync took a newer Chronos's
|
||||
/// settings (any thread): everything that changes the project is disabled and says why, and a toast says so (for a
|
||||
|
||||
@@ -3,12 +3,16 @@ using System.IO;
|
||||
using System.Windows.Input;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Settings;
|
||||
using Chronos.App.Shell;
|
||||
using Chronos.App.Workspace;
|
||||
using Chronos.Core.Advice;
|
||||
using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Export;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Core.Video;
|
||||
using Chronos.Data;
|
||||
using Chronos.Data.Processing;
|
||||
using Chronos.Ui.Controls;
|
||||
using Chronos.Ui.Mvvm;
|
||||
@@ -403,6 +407,42 @@ public sealed class ExportTab : EditorTab
|
||||
? Loc.Plural("Editor.Export.History", renders.Count, Formatting.Date(renders[0].Created))
|
||||
: Loc.L("Editor.Export.NoHistory");
|
||||
|
||||
/// <summary>A workspace project's renders made on this PC that are not at its home yet (phase 5c): "Not sent".</summary>
|
||||
public bool HasUnsent => Editor.Session.Source is WorkspaceSequenceSource { UnsentRenders: > 0 };
|
||||
|
||||
/// <summary>Send again: queues the sending home of every render made here not sent yet; disabled while one is queued from here.</summary>
|
||||
public ICommand SendAgainCommand => _sendAgain ??= new AsyncRelayCommand(SendAgainAsync, () => HasUnsent && !_sendQueued);
|
||||
|
||||
private AsyncRelayCommand? _sendAgain;
|
||||
|
||||
/// <summary>A send was queued from here and the ledger was not read again since.</summary>
|
||||
private bool _sendQueued;
|
||||
|
||||
/// <summary>What Send again does, worded for the project's home.</summary>
|
||||
public string SendAgainToolTip => WorkspaceText.ForHome("Tooltips.Editor.Render.SendAgain", Editor.Session.Source is WorkspaceSequenceSource { IsServerHome: true });
|
||||
|
||||
private async Task SendAgainAsync()
|
||||
{
|
||||
if (Editor.Session.Source is not WorkspaceSequenceSource source) return;
|
||||
try
|
||||
{
|
||||
_sendQueued = await Editor.Shell.Services.Workspace.SendRendersAsync(source.ProjectId);
|
||||
_sendAgain?.RaiseCanExecuteChanged();
|
||||
if (_sendQueued)
|
||||
Editor.Shell.Notify(Loc.L("Editor.Render.Sending"), Editor.Title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Editor.Shell.Navigate(SectionKey.Jobs));
|
||||
}
|
||||
catch (Exception ex) when (ex is WorkspaceException or IOException or InvalidDataException or UnauthorizedAccessException or DatabaseException)
|
||||
{
|
||||
Log.Warning("editor", $"The renders of workspace project {source.ProjectId} could not be queued to be sent", ex);
|
||||
Editor.Shell.Notify(Loc.L("Editor.Render.SendFailed"), ex is WorkspaceException ? ex.Message : ErrorText.For(ex), isError: true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Why the renders are not in the library (or on the server) yet, and that their files stay in the workspace.</summary>
|
||||
public string? UnsentToolTip => Editor.Session.Source is WorkspaceSequenceSource { UnsentRenders: > 0 } source
|
||||
? Loc.L(source.IsServerHome ? "Tooltips.Editor.Render.NotSent.Server" : "Tooltips.Editor.Render.NotSent")
|
||||
: null;
|
||||
|
||||
public IReadOnlyList<string> Batch => Export.Batch;
|
||||
|
||||
/// <summary>Completes when the card estimates in flight are done.</summary>
|
||||
@@ -476,6 +516,9 @@ public sealed class ExportTab : EditorTab
|
||||
|
||||
public override void OnContentChanged()
|
||||
{
|
||||
// The ledger was read again: Send again goes by what it holds now.
|
||||
_sendQueued = false;
|
||||
_sendAgain?.RaiseCanExecuteChanged();
|
||||
LoadCards();
|
||||
if (SelectedCopy is null || !SavedCopies.Contains(SelectedCopy)) SelectedCopy = SavedCopies.FirstOrDefault();
|
||||
base.OnContentChanged();
|
||||
|
||||
@@ -11,8 +11,8 @@ public sealed class SequenceJobs(Guid sequenceId)
|
||||
{
|
||||
private readonly Dictionary<Guid, Job> _active = [];
|
||||
|
||||
/// <summary>An analysis or render runs: settings wait.</summary>
|
||||
public bool IsBusy => _active.Values.Any(j => j.State == JobState.Running);
|
||||
/// <summary>An analysis or render runs: settings wait (a local render's send home does not hold them).</summary>
|
||||
public bool IsBusy => _active.Values.Any(j => j.State == JobState.Running && j.Kind != JobKind.WorkspaceSend);
|
||||
|
||||
/// <summary>A deep analysis waits, runs or is paused.</summary>
|
||||
public bool IsAnalysing => _active.Values.Any(j => j.Kind == JobKind.DeepAnalyse);
|
||||
@@ -20,16 +20,30 @@ public sealed class SequenceJobs(Guid sequenceId)
|
||||
/// <summary>The job to show: one running, else one paused, else the oldest waiting; null when there is none.</summary>
|
||||
public Job? Shown => First(_active.Values);
|
||||
|
||||
/// <summary>
|
||||
/// The job a server sequence's header shows, chosen as <see cref="Shown"/> is among the jobs that run at its home: a
|
||||
/// workspace project's render on this PC and its send home are this PC's jobs (the Jobs screen and the Export tab say
|
||||
/// them), never the server's.
|
||||
/// </summary>
|
||||
public Job? ShownAtHome => First(_active.Values.Where(j => !IsLocalKind(j.Kind)));
|
||||
|
||||
/// <summary>A workspace project's render on this PC or its send home (phase 5c): this PC's job whatever the home.</summary>
|
||||
public static bool IsLocalKind(JobKind kind) => kind is JobKind.WorkspaceRender or JobKind.WorkspaceSend;
|
||||
|
||||
/// <summary>The job of <paramref name="kind"/> to show, chosen as <see cref="Shown"/> is (the Edit path's steps).</summary>
|
||||
public Job? Active(JobKind kind) => First(_active.Values.Where(j => j.Kind == kind));
|
||||
|
||||
/// <summary>An analysis or render of this sequence.</summary>
|
||||
/// <summary>An analysis or render of this sequence, a workspace project's render on this PC or its send home (phase 5c).</summary>
|
||||
public bool Concerns(Job job)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(job);
|
||||
return job.TargetIds.Contains(sequenceId) && job.Kind is JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render;
|
||||
return job.TargetIds.Contains(sequenceId) && IsSequenceKind(job.Kind);
|
||||
}
|
||||
|
||||
/// <summary>The kinds the editor follows.</summary>
|
||||
public static bool IsSequenceKind(JobKind kind) =>
|
||||
kind is JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render or JobKind.WorkspaceRender or JobKind.WorkspaceSend;
|
||||
|
||||
/// <summary>The job is one of those that wait, run or are paused.</summary>
|
||||
public bool IsActive(Guid jobId) => _active.ContainsKey(jobId);
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ internal sealed class ServerJobs : IAsyncDisposable
|
||||
_changed(job);
|
||||
}
|
||||
|
||||
private bool Concerns(Job job) => job.TargetIds.Contains(_sequenceId) && job.Kind is JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render;
|
||||
private bool Concerns(Job job) => job.TargetIds.Contains(_sequenceId) && SequenceJobs.IsSequenceKind(job.Kind);
|
||||
|
||||
/// <summary>A sequence deleted on the server reads as gone, like a local one removed from the index.</summary>
|
||||
internal static async Task<T> Call<T>(Func<Task<T>> call)
|
||||
|
||||
@@ -29,6 +29,9 @@ public interface IProjectRenders
|
||||
{
|
||||
/// <summary>The jobs that render <paramref name="export"/> of <paramref name="project"/> (the editor's settings, positions on the source's frames).</summary>
|
||||
IReadOnlyList<ArchiveJobRequest> RenderRequests(Sequence sequence, ProjectSettings project, ExportSettings export, int sourceWidth, int sourceHeight);
|
||||
|
||||
/// <summary>The renders run on this PC (a workspace project holding its originals, phase 5c), whatever the home.</summary>
|
||||
bool RendersLocally { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -95,6 +98,8 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
private FramePhotos _photos = new([]);
|
||||
private BundleWorkspace? _workspace;
|
||||
private bool _readOnly;
|
||||
private bool _holdsOriginals;
|
||||
private int _unsent;
|
||||
private int _disposed;
|
||||
|
||||
/// <param name="server">The server the project's home is (phase 5b); null for a project of this PC's archive.</param>
|
||||
@@ -136,6 +141,15 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
/// <summary>Settings of a newer Chronos: shown, never saved.</summary>
|
||||
public bool IsReadOnly => Volatile.Read(ref _readOnly);
|
||||
|
||||
/// <summary>
|
||||
/// The media read last hold the originals (phase 5c): the project renders on this PC's engine from them, into its
|
||||
/// <c>exports/</c>, and the renders are sent home after (<see cref="JobKind.WorkspaceRender"/>), also for a server home.
|
||||
/// </summary>
|
||||
public bool RendersLocally => Volatile.Read(ref _holdsOriginals);
|
||||
|
||||
/// <summary>The local renders of the project's ledger not at the home yet, as read last.</summary>
|
||||
public int UnsentRenders => Volatile.Read(ref _unsent);
|
||||
|
||||
public bool IsOutdated => false;
|
||||
|
||||
/// <summary>The library's values and the editor's are asked about where both changed a setting, as a sync asks.</summary>
|
||||
@@ -179,6 +193,7 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
IReadOnlyList<Render> renders = row is null ? [] : await _db.Renders.ListBySequenceAsync(home.SequenceId, cancellationToken);
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
renders = [.. renders, .. UnsentOf(session.Project, home.SequenceId)];
|
||||
var frames = media.Frames;
|
||||
Swap(media, index, session.Bundle.Workspace!, session.IsReadOnly);
|
||||
var times = frames.Where(f => f.CapturedAt is not null).Select(f => f.CapturedAt!.Value).Order().ToList();
|
||||
@@ -278,6 +293,7 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
Created = r.Created,
|
||||
ProducedBy = r.ProducedBy,
|
||||
}).ToList() ?? [];
|
||||
renders = [.. renders.Concat(UnsentOf(session.Project, home.SequenceId)).OrderByDescending(r => r.Created)];
|
||||
var (deep, otherFrames) = ServerReport(report, session.Project.AnalysisPath, frames.Count);
|
||||
var context = SequenceContext.FromFrames(frames);
|
||||
return new SequenceContent(sequence, frames, session.Working, LightAnalyzer.Analyze(frames), deep, context.SourceWidth, context.SourceHeight, null, renders, [])
|
||||
@@ -495,7 +511,9 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
/// <remarks>A project whose home is a server queues its analyses and renders there; while this PC is not signed in to it, they are refused saying so.</remarks>
|
||||
public async Task<Guid> SubmitAsync(ArchiveJobRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_server is not null) return await ServerJobsOrThrow().SubmitAsync(request, cancellationToken);
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
// A render from the workspace's originals and its send run on this PC's engine, whatever the home (phase 5c).
|
||||
if (_server is not null && !RunsHere(request.Kind)) return await ServerJobsOrThrow().SubmitAsync(request, cancellationToken);
|
||||
if (_engine is null) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
|
||||
var job = await _engine.EnqueueAsync(request, cancellationToken: cancellationToken);
|
||||
return job.Id;
|
||||
@@ -504,26 +522,40 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
/// <remarks>A server home's jobs are the server's; none are listed while it cannot be reached (the project opens all the same).</remarks>
|
||||
public async Task<IReadOnlyList<Job>> ListJobsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if (_server is null) return (await _db.Jobs.ListAsync(null, JobsListed, null, cancellationToken)).Items;
|
||||
if (Api() is null || Volatile.Read(ref _serverJobs) is not { } jobs) return [];
|
||||
var local = (await _db.Jobs.ListAsync(null, JobsListed, null, cancellationToken)).Items;
|
||||
if (_server is null) return local;
|
||||
// This PC's renders from the originals and their sends beside the server's jobs (phase 5c).
|
||||
IReadOnlyList<Job> here = [.. local.Where(j => RunsHere(j.Kind))];
|
||||
if (Api() is null || Volatile.Read(ref _serverJobs) is not { } jobs) return here;
|
||||
try
|
||||
{
|
||||
return await jobs.ListAsync(cancellationToken);
|
||||
return [.. (await jobs.ListAsync(cancellationToken)).Concat(here)];
|
||||
}
|
||||
catch (Exception ex) when (ServerProjectHome.IsUnavailable(ex, cancellationToken) || ex is ChronosApiException or EditorException)
|
||||
{
|
||||
Log.Info("editor", $"The server's jobs of workspace project {ProjectId} are not read now: {ex.Message}");
|
||||
return [];
|
||||
return here;
|
||||
}
|
||||
}
|
||||
|
||||
public Task CancelJobAsync(Guid jobId, CancellationToken cancellationToken) => _server is not null
|
||||
? ServerJobsOrThrow().CancelAsync(jobId, cancellationToken)
|
||||
: (_engine ?? throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"))).CancelAsync(jobId, cancellationToken);
|
||||
public async Task CancelJobAsync(Guid jobId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_server is not null && !await IsLocalJobAsync(jobId, cancellationToken)) await ServerJobsOrThrow().CancelAsync(jobId, cancellationToken);
|
||||
else await (_engine ?? throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"))).CancelAsync(jobId, cancellationToken);
|
||||
}
|
||||
|
||||
public Task RetryJobAsync(Guid jobId, CancellationToken cancellationToken) => _server is not null
|
||||
? ServerJobsOrThrow().RetryAsync(jobId, cancellationToken)
|
||||
: (_engine ?? throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"))).ResumeAsync(jobId, cancellationToken);
|
||||
public async Task RetryJobAsync(Guid jobId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_server is not null && !await IsLocalJobAsync(jobId, cancellationToken)) await ServerJobsOrThrow().RetryAsync(jobId, cancellationToken);
|
||||
else await (_engine ?? throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"))).ResumeAsync(jobId, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>The kinds a workspace project runs on this PC's engine whatever its home: a render from its originals and its send home.</summary>
|
||||
private static bool RunsHere(JobKind kind) => kind is JobKind.WorkspaceRender or JobKind.WorkspaceSend;
|
||||
|
||||
/// <summary>A job of this PC's engine that runs here whatever the home (<see cref="RunsHere"/>).</summary>
|
||||
private async Task<bool> IsLocalJobAsync(Guid jobId, CancellationToken cancellationToken) =>
|
||||
await _db.Jobs.GetAsync(jobId, cancellationToken) is { } job && RunsHere(job.Kind);
|
||||
|
||||
/// <summary>
|
||||
/// The render at the home (owner review 2, R8: edit with proxies, render where the originals are): one job per preset
|
||||
@@ -542,6 +574,7 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
ArgumentNullException.ThrowIfNull(export);
|
||||
var portable = ProjectContent.ToPortable(project with { Export = export }, Photos);
|
||||
var hash = ProjectContent.Hash(portable);
|
||||
if (RendersLocally && Workspace is { } workspace) return LocalRenderRequests(sequence, workspace.Home, portable, hash, export, sourceWidth, sourceHeight);
|
||||
if (_server is not null)
|
||||
{
|
||||
if (InStepWithHome(project) is { } basis)
|
||||
@@ -566,6 +599,75 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
return [.. requests.Select(r => r with { ParametersJson = WithoutVersion(r.ParametersJson) })];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The render on this PC from the originals the workspace holds (phase 5c): one <see cref="JobKind.WorkspaceRender"/> per
|
||||
/// preset with the project's portable settings, naming the head version of <c>versions/</c> when the settings are the
|
||||
/// ones it holds (the render records it; an unsaved working state renders without a version), sent home after.
|
||||
/// </summary>
|
||||
private IReadOnlyList<ArchiveJobRequest> LocalRenderRequests(Sequence sequence, BundleHome home, string portable, string hash, ExportSettings export,
|
||||
int sourceWidth, int sourceHeight)
|
||||
{
|
||||
var head = HeadVersion(hash);
|
||||
var version = new ProjectVersion { Id = head ?? Guid.Empty, ProjectId = ProjectId, Number = 0, SettingsJson = portable, ContentHash = hash };
|
||||
var root = _sync.Store.Root;
|
||||
var server = home.IsArchive ? null : home.Server;
|
||||
return
|
||||
[
|
||||
.. ProcessingJobs.RenderVersion(sequence, version, export, sourceWidth, sourceHeight).Select(r => WorkspaceJobs.Render(home.SequenceId,
|
||||
r.Label ?? sequence.DisplayTitle, root, ProjectId, head, (head is null ? WithoutVersion(r.ParametersJson) : r.ParametersJson)!, server)),
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>The id of the newest version the workspace holds when it holds <paramref name="hash"/>; null otherwise.</summary>
|
||||
private Guid? HeadVersion(string hash)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Project.Versions() is [.., var last] && string.Equals(last.ContentHash, hash, StringComparison.OrdinalIgnoreCase) ? last.Id : null;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Warning("editor", $"The versions of workspace project {ProjectId} cannot be read; the render names none", ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The local renders of the project's ledger not at the home yet, as renders of <paramref name="sequenceId"/> (newest first).</summary>
|
||||
private IReadOnlyList<Render> UnsentOf(WorkspaceProject project, Guid sequenceId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var unsent = project.ReadRenders().Unsent;
|
||||
Volatile.Write(ref _unsent, unsent.Count);
|
||||
return
|
||||
[
|
||||
.. unsent.OrderByDescending(e => e.Rendered).Select(e => new Render
|
||||
{
|
||||
Id = e.RenderId,
|
||||
SequenceId = sequenceId,
|
||||
PresetName = e.PresetName,
|
||||
OutputPath = project.ExportFile(e.File),
|
||||
Codec = e.Codec,
|
||||
Width = e.Width,
|
||||
Height = e.Height,
|
||||
Fps = e.Fps,
|
||||
DurationSeconds = e.DurationSeconds,
|
||||
Bytes = e.Size,
|
||||
Created = e.Rendered,
|
||||
ProducedBy = Environment.MachineName,
|
||||
ProjectId = e.ProjectId,
|
||||
ProjectVersionId = e.ProjectVersionId,
|
||||
}),
|
||||
];
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Warning("editor", $"The render ledger of workspace project {ProjectId} cannot be read", ex);
|
||||
Volatile.Write(ref _unsent, 0);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The home's version the project is in step with: its base, when no version waits to be sent and the editor's project
|
||||
/// (<paramref name="project"/>) holds what the base holds; null otherwise.
|
||||
@@ -643,6 +745,7 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
_photos = index.Photos;
|
||||
_standIns = [.. index.Frames.Where(f => f.IsStandIn).Select(f => f.Id)];
|
||||
_workspace = workspace;
|
||||
_holdsOriginals = index.HoldsOriginals;
|
||||
changed = _readOnly != readOnly;
|
||||
_readOnly = readOnly;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user