CopyEngine puts the planners together behind ICopyEngine so the App can find, compare, integrate, merge, link, unlink and keep pairs apart. It also moves photos that one side deleted to the other side's trash. Each trash step re-reads both sides when applied, and nothing moves if any photo was restored since the dry run. The sync agent now queues the new photos of pairs that were integrated with automatic photos, both ways, at background priority. Failures back off, and three in a row are reported so the pair can show "not sent". On a metered connection, integrations are held like other server transfers. AppServices builds the engine and registers the Integrate and Merge handlers. A CopyWatch looks for local copies after start and after jobs that change photos. Merges wait for workspace work that has not been sent home. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
3.1 KiB
C#
72 lines
3.1 KiB
C#
using Chronos.App.Server;
|
|
using Chronos.Core.Model;
|
|
using Chronos.Data.Archiving.Jobs;
|
|
using Chronos.Data.Workspaces;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.App.Tests.Server;
|
|
|
|
/// <summary>
|
|
/// Which jobs "Pause metered transfers" holds (Server.html, phase 5c): uploads, the sync's downloads, and the workspace's copies from and renders
|
|
/// sent to a server, and the integrations of pairs with a server sequence; never a copy from or a send to this PC's archive, nor a merge.
|
|
/// </summary>
|
|
public sealed class UploadHoldTests
|
|
{
|
|
private const string Server = "https://nas.local:8443";
|
|
private static readonly Guid SequenceId = Guid.CreateVersion7();
|
|
private static readonly Guid ProjectId = Guid.CreateVersion7();
|
|
private const string Root = @"C:\Users\me\Chronos\workspace";
|
|
|
|
private static Job Of(ArchiveJobRequest request) => new()
|
|
{
|
|
Id = Guid.CreateVersion7(),
|
|
Kind = request.Kind,
|
|
TargetIds = request.Targets,
|
|
TargetLabel = request.Label,
|
|
ParametersJson = request.ParametersJson,
|
|
State = JobState.Queued,
|
|
Created = DateTimeOffset.UtcNow,
|
|
};
|
|
|
|
private static Job Of(JobKind kind, string? parameters = null) => new()
|
|
{
|
|
Id = Guid.CreateVersion7(),
|
|
Kind = kind,
|
|
TargetIds = [SequenceId],
|
|
ParametersJson = parameters,
|
|
State = JobState.Queued,
|
|
Created = DateTimeOffset.UtcNow,
|
|
};
|
|
|
|
[Test]
|
|
public void TransfersWithAServerAreHeld()
|
|
{
|
|
Assert.True(UploadHold.Holds(Of(JobKind.UploadCommit)));
|
|
// The sync's downloads too: the option's tooltip says "uploads and downloads".
|
|
Assert.True(UploadHold.Holds(Of(JobKind.Download)));
|
|
Assert.True(UploadHold.Holds(Of(WorkspaceJobs.CopyFromServer(SequenceId, "Harbour", Server, Root, ProjectId))));
|
|
Assert.True(UploadHold.Holds(Of(WorkspaceJobs.Send(SequenceId, "Harbour", Root, ProjectId, [], Server))));
|
|
Assert.SequenceEqual([JobKind.UploadCommit, JobKind.Download, JobKind.WorkspaceCopy, JobKind.WorkspaceSend, JobKind.Integrate], UploadHold.Kinds);
|
|
}
|
|
|
|
[Test]
|
|
public void AnIntegrationIsHeldAMergeIsNot()
|
|
{
|
|
// An integration always moves photos with a server (owner review 6, #73); a merge of two local sequences never does.
|
|
Assert.True(UploadHold.Holds(Of(JobKind.Integrate)));
|
|
Assert.False(UploadHold.Holds(Of(JobKind.MergeSequences)));
|
|
}
|
|
|
|
[Test]
|
|
public void TransfersWithThisPcsLibraryAndOtherJobsAreNot()
|
|
{
|
|
var sequence = new Sequence { Id = SequenceId, ArchiveId = Guid.CreateVersion7(), Title = "Harbour", Folder = "2026/harbour" };
|
|
Assert.False(UploadHold.Holds(Of(WorkspaceJobs.Copy(sequence, Root, ProjectId))));
|
|
Assert.False(UploadHold.Holds(Of(WorkspaceJobs.Send(SequenceId, "Harbour", Root, ProjectId, []))));
|
|
Assert.False(UploadHold.Holds(Of(JobKind.Render)));
|
|
// Parameters that cannot be read are not held: the job fails with its reason.
|
|
Assert.False(UploadHold.Holds(Of(JobKind.WorkspaceSend, "{not json")));
|
|
Assert.False(UploadHold.Holds(Of(JobKind.WorkspaceCopy)));
|
|
}
|
|
}
|