feat(workspace): copy originals into the workspace and choose the project Edit opens
Phase 5c P1. A workspace copy of kind "originals" now copies each frame's original beside its proxy, so a later local render has full-quality input: streamed into a .part file, hashed as written, checked against the home's SHA-256, renamed and read back. Archive and server homes both work, a stopped copy resumes (originals: checkpoint), and the space check counts the originals. A frame whose original is gone, damaged or refused keeps its proxy and the job says how many; the copy does not fail. Stale originals are deleted only when the home holds the same SHA-256, otherwise moved to the workspace's trash. Proxies only... plans first (every original hashed against the home's frames), asks for an explicit confirmation, rewrites the media to proxies before it touches a file, refuses a plan that changed since, and trashes what the home no longer holds instead of deleting it. Edit: Open in workspace offers Originals (the settings' default, disabled when the drive lacks room) with the originals' size for archive and server homes; Settings > Workspace > Open project picks Last used, Main or asks which; each open is recorded for the clean-up. The project menu gains Copy originals... and Proxies only..., refused while changes are unsaved or jobs of the sequence run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e1c67f531
commit
0c51d11080
14 files changed
+1397
-70
No files matched your search
@@ -81,6 +81,8 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
private bool _isSyncing;
|
||||
private bool _homeFramesChanged;
|
||||
private Guid _copyJob;
|
||||
private bool _copyingOriginals;
|
||||
private bool _changingMedia;
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>Counts the editor's changes, so only the last one's state read applies.</summary>
|
||||
@@ -110,6 +112,8 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
RenameCommand = new AsyncRelayCommand(OpenRenameAsync);
|
||||
DeleteCommand = new AsyncRelayCommand(DeleteAsync, () => !IsMain);
|
||||
RemoveCopyCommand = new AsyncRelayCommand(OpenRemoveCopyAsync);
|
||||
CopyOriginalsCommand = new AsyncRelayCommand(CopyOriginalsAsync, () => !HoldsOriginals && !IsMediaBusy);
|
||||
ProxiesOnlyCommand = new AsyncRelayCommand(ProxiesOnlyAsync, () => HoldsOriginals && !IsMediaBusy);
|
||||
source.JobChanged += OnJobChanged;
|
||||
session.ProjectChanged += OnProjectChanged;
|
||||
host.HomeChanged += OnHomeChanged;
|
||||
@@ -193,6 +197,27 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
|
||||
public ICommand UpdateMediaCommand => _updateMedia;
|
||||
|
||||
/// <summary>The workspace holds the project's originals besides its proxies (phase 5c): renders run on this PC.</summary>
|
||||
public bool HoldsOriginals => _source.Workspace?.Media.Kind == BundleMedia.Originals;
|
||||
|
||||
/// <summary>
|
||||
/// The media cannot change now: changes not saved as a version, a sync or a copy of the media running (the jobs of the
|
||||
/// sequence are asked when the command runs).
|
||||
/// </summary>
|
||||
public bool IsMediaBusy => _changingMedia || _isSyncing || _copyJob != Guid.Empty || _status is { Modified: true, ReadOnly: false };
|
||||
|
||||
/// <summary>Copy originals… (phase 5c): the project's originals into the workspace, to render on this PC.</summary>
|
||||
public ICommand CopyOriginalsCommand { get; }
|
||||
|
||||
/// <summary>Proxies only… (phase 5c): the originals copied here deleted once the home is checked to hold each one.</summary>
|
||||
public ICommand ProxiesOnlyCommand { get; }
|
||||
|
||||
public string CopyOriginalsToolTip => IsMediaBusy ? Loc.L("Tooltips.Editor.Project.MediaBusy")
|
||||
: WorkspaceText.ForHome("Tooltips.Editor.Project.CopyOriginals", IsServerHome);
|
||||
|
||||
public string ProxiesOnlyToolTip => IsMediaBusy ? Loc.L("Tooltips.Editor.Project.MediaBusy")
|
||||
: WorkspaceText.ForHome("Tooltips.Editor.Project.ProxiesOnly", IsServerHome);
|
||||
|
||||
/// <summary>Reads where the project stands (against its home) and whether the home's frames moved.</summary>
|
||||
public async Task RefreshAsync()
|
||||
{
|
||||
@@ -644,6 +669,130 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copy originals…: refused while the media cannot change (<see cref="IsMediaBusy"/>, or a job of the sequence waits or
|
||||
/// runs); otherwise the copy is queued, the banner says it runs, and the editor reads the media again once it is done.
|
||||
/// </summary>
|
||||
private async Task CopyOriginalsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
await StoreEditAsync();
|
||||
if (await MediaRefusalAsync() is { } refusal)
|
||||
{
|
||||
_ui.Notify(Loc.L("Editor.Workspace.CopyFailed"), refusal, isError: true);
|
||||
return;
|
||||
}
|
||||
var job = await _host.QueueOriginalsCopyAsync(ProjectId);
|
||||
_copyJob = job.Id;
|
||||
_copyingOriginals = true;
|
||||
RaiseState();
|
||||
_ui.Notify(Loc.L("Editor.Workspace.CopyingOriginals"), _session.Content.Sequence.DisplayTitle, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"));
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning("workspace", $"The originals of project {ProjectId} could not be queued for copy", ex);
|
||||
_ui.Notify(Loc.L("Editor.Workspace.CopyFailed"), WorkspaceText.Failure(ex, IsServerHome), isError: true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Proxies only…: the plan (each original hashed and weighed against the home, read now), confirmed by the user, then
|
||||
/// applied; the home out of reach, or anything changed since the plan, removes nothing.
|
||||
/// </summary>
|
||||
private async Task ProxiesOnlyAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
await StoreEditAsync();
|
||||
if (await MediaRefusalAsync() is { } refusal)
|
||||
{
|
||||
_ui.Notify(Loc.L("Editor.Workspace.OriginalsNotRemoved"), refusal, isError: true);
|
||||
return;
|
||||
}
|
||||
SetChangingMedia(true);
|
||||
var plan = await _host.PlanProxiesOnlyAsync(ProjectId);
|
||||
if (_disposed) return;
|
||||
var detail = new List<string>
|
||||
{
|
||||
Loc.L("Editor.ProxiesOnly.Originals", Formatting.Count(plan.Originals)),
|
||||
Loc.L("Editor.ProxiesOnly.Size", Formatting.Bytes(plan.Bytes)),
|
||||
};
|
||||
if (plan.ToTrash > 0) detail.Add(Loc.L("Editor.ProxiesOnly.ToTrash", Formatting.Count(plan.ToTrash)));
|
||||
if (!_ui.Confirm(new ConfirmRequest
|
||||
{
|
||||
Heading = Loc.L("Editor.ProxiesOnly.Title", Name),
|
||||
Message = WorkspaceText.ForHome("Editor.ProxiesOnly.Message", IsServerHome),
|
||||
Detail = string.Join(Environment.NewLine, detail),
|
||||
IsDetailMonospaced = false,
|
||||
DetailToolTip = plan.ToTrash > 0 ? WorkspaceText.ForHome("Tooltips.Editor.ProxiesOnly.ToTrash", IsServerHome) : null,
|
||||
SafeText = Loc.L("Editor.Project.Keep"),
|
||||
SafeToolTip = Loc.L("Tooltips.Editor.ProxiesOnly.Keep"),
|
||||
ActionText = Loc.L("Editor.ProxiesOnly.Action"),
|
||||
ActionToolTip = Loc.L("Tooltips.Editor.ProxiesOnly.Action"),
|
||||
IsDestructive = true,
|
||||
}))
|
||||
return;
|
||||
var trashed = await _host.ProxiesOnlyAsync(ProjectId, plan);
|
||||
if (_disposed) return;
|
||||
await _session.ReloadAsync();
|
||||
_ui.Notify(Loc.L("Editor.Workspace.OriginalsRemoved"),
|
||||
trashed > 0 ? Loc.L("Editor.ProxiesOnly.ToTrash", Formatting.Count(trashed)) : _session.Content.Sequence.DisplayTitle);
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning("workspace", $"The originals of project {ProjectId} were not removed", ex);
|
||||
_ui.Notify(Loc.L("Editor.Workspace.OriginalsNotRemoved"), WorkspaceText.Failure(ex, IsServerHome), isError: true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
SetChangingMedia(false);
|
||||
await RefreshAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Why the media cannot change now (<c>Errors.Workspace.MediaBusy</c>): changes not saved as a version, a copy or sync
|
||||
/// running, or an analysis, render or workspace job of the sequence waiting or running; null when they can.
|
||||
/// </summary>
|
||||
private async Task<string?> MediaRefusalAsync()
|
||||
{
|
||||
var local = await _host.StatusAsync(ProjectId, askHome: false);
|
||||
if (_disposed) return null;
|
||||
Apply(WithLocal(_status, local));
|
||||
if (IsMediaBusy) return Loc.L("Errors.Workspace.MediaBusy");
|
||||
var jobs = await _source.ListJobsAsync(CancellationToken.None);
|
||||
var sequenceId = SequenceId;
|
||||
return jobs.Any(j => j.State is JobState.Queued or JobState.Running or JobState.Paused && j.TargetIds.Contains(sequenceId)
|
||||
&& j.Kind is JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render or JobKind.WorkspaceCopy or JobKind.WorkspaceRender
|
||||
or JobKind.WorkspaceSend)
|
||||
? Loc.L("Errors.Workspace.MediaBusy")
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>The copy of the originals ended: said, with the frames that have none (they stay proxies, and a local render waits for them).</summary>
|
||||
private void NotifyOriginalsCopied()
|
||||
{
|
||||
int missing;
|
||||
try
|
||||
{
|
||||
missing = _source.Project.ReadMedia()?.Frames.Count(f => f.Original is null) ?? 0;
|
||||
}
|
||||
catch (Exception ex) when (ex is System.IO.IOException or System.IO.InvalidDataException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Warning("workspace", $"The media of project {ProjectId} could not be read after the copy of its originals", ex);
|
||||
missing = 0;
|
||||
}
|
||||
if (missing == 0) _ui.Notify(Loc.L("Editor.Workspace.OriginalsCopied"), _session.Content.Sequence.DisplayTitle);
|
||||
else _ui.Notify(Loc.L("Editor.Workspace.OriginalsCopied"), Loc.L("Editor.Workspace.OriginalsMissing", Formatting.Count(missing)));
|
||||
}
|
||||
|
||||
private void SetChangingMedia(bool changing)
|
||||
{
|
||||
_changingMedia = changing;
|
||||
RaiseState();
|
||||
}
|
||||
|
||||
/// <summary>The editor's last edit stored in the working state before an operation reads it.</summary>
|
||||
/// <exception cref="WorkspaceException">It could not be stored (it is retried in the background; nothing was lost).</exception>
|
||||
private async Task StoreEditAsync()
|
||||
@@ -787,10 +936,13 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
{
|
||||
if (_disposed || job.Id != _copyJob) return;
|
||||
_copyJob = Guid.Empty;
|
||||
var originals = _copyingOriginals;
|
||||
_copyingOriginals = false;
|
||||
if (job.State == JobState.Failed) _ui.Notify(Loc.L("Editor.Workspace.CopyFailed"), job.Error ?? _session.Content.Sequence.DisplayTitle, isError: true);
|
||||
try
|
||||
{
|
||||
if (job.State == JobState.Done) await _session.ReloadAsync();
|
||||
if (job.State == JobState.Done && originals) NotifyOriginalsCopied();
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
@@ -836,6 +988,10 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
OnPropertyChanged(nameof(RemoveCopyToolTip));
|
||||
OnPropertyChanged(nameof(MediaChangedToolTip));
|
||||
OnPropertyChanged(nameof(UpdateMediaToolTip));
|
||||
OnPropertyChanged(nameof(HoldsOriginals));
|
||||
OnPropertyChanged(nameof(IsMediaBusy));
|
||||
OnPropertyChanged(nameof(CopyOriginalsToolTip));
|
||||
OnPropertyChanged(nameof(ProxiesOnlyToolTip));
|
||||
_updateMedia.RaiseCanExecuteChanged();
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user