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:
1 parent
8256b72913
commit
64fc5521c0
30 files changed
+1017
-98
No files matched your search
@@ -35,6 +35,20 @@ public static class WorkspaceJobs
|
||||
/// parameters name).
|
||||
/// </summary>
|
||||
public static IReadOnlyList<IJobHandler> CreateHandlers(ChronosDatabase db, ArchiveService archives) => [new WorkspaceCopyJobHandler(db, archives)];
|
||||
|
||||
/// <summary>
|
||||
/// What a first copy of a sequence's proxies writes into a workspace, as the copy reckons it before it starts (the
|
||||
/// archive's proxies' sizes, an estimate for those it makes), and the free bytes on <paramref name="workspaceRoot"/>'s
|
||||
/// drive (null when it cannot be measured): "Open in workspace" shows both. The copy keeps <see cref="CopySpaceReserve"/>
|
||||
/// free besides.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">The index has no such sequence or archive.</exception>
|
||||
public static Task<(long Bytes, long? Free)> CopyFactsAsync(ChronosDatabase db, ArchiveService archives, Guid sequenceId, string workspaceRoot,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
new WorkspaceCopyJobHandler(db, archives).FactsAsync(sequenceId, workspaceRoot, cancellationToken);
|
||||
|
||||
/// <summary>Bytes the copy leaves free on the workspace's drive besides what it copies.</summary>
|
||||
public static long CopySpaceReserve => WorkspaceCopyJobHandler.SpaceReserve;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -62,7 +76,7 @@ internal sealed class WorkspaceCopyJobHandler(ChronosDatabase db, ArchiveService
|
||||
private static readonly TimeSpan CheckpointEvery = TimeSpan.FromSeconds(5);
|
||||
|
||||
/// <summary>Bytes left free on the workspace's drive besides the copy, as a download keeps (<see cref="SyncTransfers"/>).</summary>
|
||||
private const long SpaceReserve = 512L << 20;
|
||||
internal const long SpaceReserve = 512L << 20;
|
||||
|
||||
/// <summary>A proxy at <see cref="ProxyEstimateEdge"/> px, when the archive has none to measure: some 1.5 MB.</summary>
|
||||
private const long ProxyEstimate = 3L << 19;
|
||||
@@ -348,11 +362,13 @@ internal sealed class WorkspaceCopyJobHandler(ChronosDatabase db, ArchiveService
|
||||
/// nothing for a frame the workspace holds a file of already (kept, or replaced by one of about its size), the archive's
|
||||
/// proxy's size where it has one, else an estimate at the proxy size the copy makes (<see cref="Estimate"/>).
|
||||
/// </summary>
|
||||
private static long[] Remaining(WorkspaceProject project, SequencePaths folder, List<Frame> frames, ProxyPolicy policy)
|
||||
{
|
||||
var held = Directory.Exists(project.ProxiesDirectory)
|
||||
private static long[] Remaining(WorkspaceProject project, SequencePaths folder, List<Frame> frames, ProxyPolicy policy) =>
|
||||
Remaining(Directory.Exists(project.ProxiesDirectory)
|
||||
? Directory.EnumerateFiles(project.ProxiesDirectory).Select(Path.GetFileName).ToHashSet(StringComparer.OrdinalIgnoreCase)
|
||||
: [];
|
||||
: [], folder, frames, policy);
|
||||
|
||||
private static long[] Remaining(HashSet<string?> held, SequencePaths folder, List<Frame> frames, ProxyPolicy policy)
|
||||
{
|
||||
var proxies = Directory.Exists(folder.Proxies)
|
||||
? new DirectoryInfo(folder.Proxies).EnumerateFiles().ToDictionary(f => f.Name, f => f.Length, StringComparer.OrdinalIgnoreCase)
|
||||
: [];
|
||||
@@ -369,6 +385,17 @@ internal sealed class WorkspaceCopyJobHandler(ChronosDatabase db, ArchiveService
|
||||
return remaining;
|
||||
}
|
||||
|
||||
/// <summary>What a first copy of the sequence writes (nothing held yet), and the free bytes of the workspace's drive.</summary>
|
||||
internal async Task<(long Bytes, long? Free)> FactsAsync(Guid sequenceId, string workspaceRoot, CancellationToken cancellationToken)
|
||||
{
|
||||
var (row, frames) = await FramesAsync(sequenceId, cancellationToken).ConfigureAwait(false);
|
||||
var archive = await db.Archives.GetAsync(row.ArchiveId, cancellationToken).ConfigureAwait(false)
|
||||
?? throw new InvalidOperationException(Loc.L("Archive.Log.SequenceMissing", sequenceId));
|
||||
var paths = new ArchivePaths(archive.RootPath);
|
||||
var policy = ManifestStore.ReadArchive(paths.ManifestPath).ProxyPolicy;
|
||||
return (Remaining([], paths.Sequence(row.Folder), frames, policy)[0], FreeBytes(workspaceRoot));
|
||||
}
|
||||
|
||||
/// <summary>A proxy's size when the archive has none to measure: some 1.5 MB at 1920 px, scaled by the area at the copy's long edge.</summary>
|
||||
private static long Estimate(Frame frame, ProxyPolicy policy)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user