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
@@ -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