fix(workspace): settle conflicts in one answer and give refused folders a way on

Phase 5a fix round 2 of owner review 2 (desktop):

- Take library's no longer commits the working state first, so a take that
  leaves only the library's values sends no empty version; the working state
  it replaces is kept aside in versions/.replaced, outside the chain.
- Conflicts list this side's value as the working state holds it, so one
  answer settles them instead of asking again for the newer value.
- A conflict of format (library saved by a newer Chronos) offers only Save
  both and Later, says why in its tooltip and shows no raw format numbers.
- Conflict lines count the photos a setting differs on ("Excluded frames
  (3)") instead of dropping the duplicates.
- A read-only library is named as such, not as offline; checkouts from it
  stay editable and their versions wait in the workspace.
- A workspace folder refused inside a library offers Choose folder, and
  Settings > Workspace gets Change...: a plan (projects left, projects found)
  is confirmed before the folder changes; nothing is moved.
- Open in workspace shows the copy's size and the drive's free space, and
  warns when the copy would not fit with its 0.5 GB reserve.
- A cancelled first copy removes the half media it wrote.
- A copy whose project.chronos cannot be read is listed as damaged instead of
  hidden, and goes only through Remove local copy > Discard, after a plan.
- Pruning keeps a version whose archive file is damaged (test added).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-03 11:52:49 +01:00
1 parent 8256b72913
commit 64fc5521c0
30 files changed
+1017 -98

No files matched your search

+55 -3
View File
@@ -232,6 +232,12 @@ public sealed class SequenceViewModel : SectionViewModel
KeepOpenSequence();
return;
}
// A copy whose working state cannot be read cannot open: its removal plan is what it offers.
if (item.IsDamaged)
{
await RemoveProjectCopyAsync(item);
return;
}
await OpenProjectAsync(item.SequenceId, item.ProjectId);
}
@@ -589,6 +595,8 @@ public sealed class SequenceViewModel : SectionViewModel
{ Main: true } => (await workspace.ProjectsOfAsync(row.Id)).FirstOrDefault(p => p.IsMain),
_ => await workspace.LastUsedAsync(row.Id),
};
// Its working state cannot be read: nothing is checked out over it (the picker offers Remove local copy).
if (entry is { Damaged: true }) throw new WorkspaceException(Loc.L("Errors.Workspace.Damaged"));
if (entry is { HasMedia: true })
{
workspace.Remember(row.Id, entry.ProjectId);
@@ -613,16 +621,43 @@ public sealed class SequenceViewModel : SectionViewModel
}
(projectId, newName) = (choice.ProjectId, choice.NewName);
}
var checkout = await workspace.CheckoutAsync(row.Id, projectId, newName);
WorkspaceCheckout checkout;
try
{
checkout = await workspace.CheckoutAsync(row.Id, projectId, newName);
}
catch (WorkspaceException ex) when (ex.FolderRefused)
{
// Nothing was written: the way on is another workspace folder, offered from the refusal.
Log.Info("workspace", $"Sequence {row.Id} not checked out: {ex.Message}");
Shell.Notify(Loc.L("Editor.Workspace.OpenFailed"), ex.Message, Loc.L("Editor.Workspace.ChooseFolder"), Loc.L("Tooltips.Editor.Workspace.ChooseFolder"),
() => _ = WorkspaceFolderChange.ChooseAsync(Shell), isError: true);
_afterOpen = null;
Shell.KeepSequence(OpenSequenceId);
return null;
}
await FollowCopyAsync(row.Id, row.DisplayTitle, checkout.Project.Id, checkout.Copy);
return null;
}
/// <summary>"Open in workspace": the projects of the sequence's home and the media; null when closed without a choice.</summary>
/// <summary>
/// "Open in workspace": the projects of the sequence's home, the media, what their copy writes and the room the
/// workspace's drive has; null when closed without a choice.
/// </summary>
private async Task<OpenChoice?> AskProjectAsync(WorkspaceHost workspace, Sequence row)
{
var projects = await workspace.HomeProjectsAsync(row.Id);
var dialog = new OpenInWorkspaceDialogViewModel(row.DisplayTitle, projects, d => CloseDialog(d));
WorkspaceCopyFacts? copy = null;
try
{
copy = await workspace.CopyFactsAsync(row.Id);
}
catch (Exception ex) when (ex is System.IO.IOException or System.IO.InvalidDataException or InvalidOperationException or DatabaseException or UnauthorizedAccessException)
{
// Only shown: the copy measures again before it writes.
Log.Info("workspace", $"The copy of sequence {row.Id} could not be measured: {ex.Message}");
}
var dialog = new OpenInWorkspaceDialogViewModel(row.DisplayTitle, projects, d => CloseDialog(d), copy: copy);
// The picker or the open sequence shows behind the dialog meanwhile, not the progress bar.
IsLoading = false;
OpenDialog(dialog);
@@ -679,6 +714,23 @@ public sealed class SequenceViewModel : SectionViewModel
Shell.Notify(Loc.L(fetch.ProjectId is null ? "Editor.Proxies.Failed" : "Editor.Workspace.CopyFailed"), job.Error ?? fetch.Title, Loc.L("Shell.Nav.Jobs"),
Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs), isError: true);
break;
// The user cancelled the first copy of a project's media: the photos it wrote go (a failed one keeps them for its retry).
case JobState.Cancelled when fetch.ProjectId is { } cancelled:
_ = RemovePartialMediaAsync(cancelled);
break;
}
}
private async Task RemovePartialMediaAsync(Guid projectId)
{
try
{
await Shell.Services.Workspace.RemovePartialMediaAsync(projectId);
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
// Copies the library can make again: they wait for the next copy, which checks each.
Log.Warning("workspace", $"The media of a cancelled copy of project {projectId} could not be removed", ex);
}
}