CI / Build and test (push) Successful in 13m44s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 16s
Release / Build, test and publish (push) Successful in 26m34s
CI / PostgreSQL 16 integration (push) Failing after 17m36s
CI / PostgreSQL 17 integration (push) Failing after 15m36s
CI / Docker image (push) Successful in 1m12s
Release / Server image (push) Failing after 15s
The same time-lapse on a server and on this PC under different ids, or twice on this PC, is recognised, compared and settled as the owner asked in owner review 6. Matches are found after each sync refresh, through the server's new photo lookup, and after the jobs that change photos. The default is to ask every time. Server › Matches offers: - Keep apart, which is remembered; - Link only and Unlink; - the Compare dialog: photos, details line by line, projects and the plan. Integrate completes both sides. Photos default to Union, projects are copied across, and a losing version goes to the trash only after a hash check. Afterwards new photos move by themselves, and deletions wait for the user. A merge of two local sequences verifies every photo before the other sequence goes to its archive's trash. Upload all local skips suspected matches and flags them. Migration 0012 adds the found_copies and copy_probes tables. Jobs 25 (Integrate) and 26 (MergeSequences) are new, and so are the server capabilities photo-lookup and upload-into. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
77 lines
3.8 KiB
C#
77 lines
3.8 KiB
C#
using Chronos.Core.Model;
|
|
using Chronos.Data.Archiving;
|
|
using Chronos.Data.Copies;
|
|
using Chronos.Data.Tests.Archiving;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Data.Tests.Copies;
|
|
|
|
/// <summary>
|
|
/// What a merge or an integration leaves in the archive's journal folder (owner review 6, #73): the maintenance pass keeps
|
|
/// the journal a retry can use and clears the one no job will read again, as it does for conversions.
|
|
/// </summary>
|
|
[Category("archive")]
|
|
public sealed class CopyJournalMaintenanceTests(TestContext context)
|
|
{
|
|
[Test]
|
|
public async Task MaintenanceClearsTheJournalOfAMergeOrIntegrateNoJobWillReadAgain()
|
|
{
|
|
await using var fx = await ArchiveFixture.CreateAsync(context);
|
|
var failed = Guid.CreateVersion7();
|
|
var done = Guid.CreateVersion7();
|
|
var cancelled = Guid.CreateVersion7();
|
|
var paused = Guid.CreateVersion7();
|
|
foreach (var (id, kind, state) in new[]
|
|
{
|
|
(failed, JobKind.MergeSequences, JobState.Failed), (done, JobKind.Integrate, JobState.Done),
|
|
(cancelled, JobKind.MergeSequences, JobState.Cancelled), (paused, JobKind.Integrate, JobState.Paused),
|
|
})
|
|
await fx.Db.Jobs.EnqueueAsync(new Job { Id = id, Kind = kind, State = state, Created = DateTimeOffset.UtcNow }, fx.Ct);
|
|
// Deleted without a cancel: the index no longer knows the job.
|
|
var deleted = Guid.CreateVersion7();
|
|
var recent = Guid.CreateVersion7();
|
|
|
|
const int Old = Housekeeping.CleanupSteps.DefaultHistoryDays + 1;
|
|
string Write(string path, int daysOld)
|
|
{
|
|
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
|
|
File.WriteAllText(path, "{}");
|
|
File.SetLastWriteTimeUtc(path, DateTime.UtcNow.AddDays(-daysOld));
|
|
return path;
|
|
}
|
|
var failedJournal = Write(MergeJournal.PathFor(fx.Paths, failed), Old);
|
|
var doneJournal = Write(IntegrateJournal.PathFor(fx.Paths, done), 0);
|
|
var cancelledJournal = Write(MergeJournal.PathFor(fx.Paths, cancelled), 0);
|
|
var pausedJournal = Write(IntegrateJournal.PathFor(fx.Paths, paused), Old);
|
|
var deletedJournal = Write(MergeJournal.PathFor(fx.Paths, deleted), Old);
|
|
var recentJournal = Write(IntegrateJournal.PathFor(fx.Paths, recent), 1);
|
|
var other = Write(Path.Combine(fx.Paths.JournalDirectory, "merge-notes.json"), Old);
|
|
|
|
var dry = await fx.Service.Maintenance.RunAsync(fx.Archive, dryRun: true, 0, _ => ValueTask.CompletedTask, fx.Ct);
|
|
Assert.SequenceEqual(new[] { doneJournal, cancelledJournal, deletedJournal }.Select(fx.Paths.ToRelative).Order(), dry.TemporaryFiles.Order());
|
|
Assert.FileExists(deletedJournal);
|
|
|
|
await fx.Service.Maintenance.RunAsync(fx.Archive, dryRun: false, 0, _ => ValueTask.CompletedTask, fx.Ct);
|
|
|
|
Assert.FileMissing(doneJournal);
|
|
Assert.FileMissing(cancelledJournal);
|
|
Assert.FileMissing(deletedJournal);
|
|
// A retry still reads these: the failed and the paused job's, and one another host may still be writing.
|
|
Assert.FileExists(failedJournal);
|
|
Assert.FileExists(pausedJournal);
|
|
Assert.FileExists(recentJournal);
|
|
Assert.FileExists(other);
|
|
}
|
|
|
|
[Test]
|
|
public void OnlyTheJournalsOfMergesAndIntegrationsAreRecognised()
|
|
{
|
|
var job = Guid.CreateVersion7();
|
|
Assert.Equal(job, ArchiveMaintenance.CopyJournalJob($"merge-{job:N}.json"));
|
|
Assert.Equal(job, ArchiveMaintenance.CopyJournalJob($"integrate-{job:N}.json"));
|
|
Assert.Null(ArchiveMaintenance.CopyJournalJob($"convert-{job:N}.json"));
|
|
Assert.Null(ArchiveMaintenance.CopyJournalJob($"merge-{job:N}.json.tmp"));
|
|
Assert.Null(ArchiveMaintenance.CopyJournalJob($"merge-{job:D}.json"));
|
|
}
|
|
}
|