Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f773edef2 | ||
|
|
65b7cdf91b | ||
|
|
6db4c2e80c |
No files matched your search
@@ -5,6 +5,8 @@ commits follow Conventional Commits (release notes are generated from them by `C
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.2.0] — 2026-11-18
|
||||
|
||||
Owner review 6 for v1.2.0 (`docs/requests/2026-11-16-owner-review-6.md`; issue #73). Upgrading from 1.1 keeps the
|
||||
archive, the database and the settings: migration 0012 runs at start and turns every existing link into a linked
|
||||
match. A 1.1 server works as before, without Integrate; a 1.2 server adds the photo lookup and uploads into a target.
|
||||
@@ -243,6 +245,15 @@ match. A 1.1 server works as before, without Integrate; a 1.2 server adds the ph
|
||||
- An upload of a sequence asked about again makes a new server sequence instead of joining, re-linking and
|
||||
overwriting the one an earlier upload made; one that joins a server sequence this PC already knows compares its
|
||||
details instead of overwriting them.
|
||||
- A second version a merge's verify files is left out of Main also when the run stopped right after filing it (a
|
||||
drive dropping out, project.json held, the app closing): the resumed merge leaves it out then.
|
||||
- A merge whose verify stopped before filing a second version, and whose photo changed before the retry, files the
|
||||
photo as it is now instead of failing on every retry; one that had filed it leaves it out of Main and asks for a
|
||||
new comparison.
|
||||
- *Upload all local* leaves out again a sequence answered *Keep here* after its server copy was deleted, and the
|
||||
answer stays; only a *Keep apart* given before the deletion lets it send the sequence.
|
||||
- An upload that joined a server sequence this PC already knew still compares its details when it is resumed or
|
||||
retried, instead of overwriting the server's title, tags, rating, notes and settings.
|
||||
|
||||
## [1.1.1] — 2026-11-16
|
||||
|
||||
|
||||
@@ -1028,3 +1028,7 @@ One line per decision: date · decision · alternative · reason.
|
||||
| 2026-11-18 | Supersedes the 2026-11-18 unlinked-404 row: a 404 for a server sequence no local copy is linked to deletes only its Candidate pairs; each Kept apart pair naming it counts the hit as a linked pair does (once per refresh, a second only after `GoneRecheck`), a listing clears the count, and Upload all local sends the local sequence only once the pair reads deleted on the server (two hits) (#73) | Count observation links in the sweep test | A single 404 (trash and restore, access withdrawn for a moment) erased the Keep apart answer, and the pair was asked again or linked by itself (owner Q1) |
|
||||
| 2026-11-18 | Download originals whose server-sequence key names a local copy paired with that server sequence (Candidate, Linked or Integrated, no link) links that copy first and fills it as a linked copy (its tombstones honoured), then compares it as a new link instead of taking the server's details; a holder with no pair (a run that stopped before linking) is joined as before (#73) | Use a key of the job for a Candidate holder too | The round-9 rule refills the local copy a 404 or Ask again left without a link; treated as new it got photos deleted here back and lost its details (owner Q3, Q4, Q6) |
|
||||
| 2026-11-18 | An upload without a target goes under a key of the job when its local sequence has a Candidate or Kept apart pair with that server, and one whose first original joins a server sequence this PC already knows (listed, linked or paired) compares it as a new link instead of sending all its details (#73) | Keep the own key for a Candidate pair | The own key filed the photos into the sequence an earlier upload made, linked it unasked and overwrote edits made there (owner Q1, Q4) |
|
||||
| 2026-11-18 | A merge's Verify stage journals a second version (`SecondVersions`, and in `VersionShas` the SHA-256 it is filed as) before it files it; a resumed verify that finds such a frame in the kept sequence leaves it out of Main again (a no-op when it already is), and one that reads other bytes for it stops with "changed" (#73) | Save the journal right after filing | The ingest commits the frame before any save can follow: a failed exclusion or a crash in between left the version in Main for good, since a resumed verify read it as the kept sequence's own |
|
||||
| 2026-11-18 | Supersedes the 2026-11-18 unlinked-404 rows on Upload all local: a Kept apart pair whose server sequence reads deleted on the server holds nothing back only when it was answered before the first 404 (`AnsweredAt < RemoteGoneAt`); a Keep here (answered after the deletion was shown) still skips the local sequence (#73) | A separate Keep here state or marker | Both answers are stored as Kept apart with the gone mark; the answer time already tells them apart, and Keep here's tooltip and design §6.3 promise Upload all local leaves it out |
|
||||
| 2026-11-18 | An upload's checkpoint names the server sequence its first original reached with `:joined` appended when that was one this PC already knew; a resumed or retried upload sends all its details only when the checkpoint names the target without that mark (a plain id from an older run still means made by this job) (#73) | Look the sequence up again in the known remotes on resume | After the first attempt the link to it exists, so a resume cannot tell a sequence it made from one it joined; only the attempt that sent the first original knows |
|
||||
| 2026-11-18 | Supersedes the 2026-11-18 `VersionShas` row where a resumed verify reads other bytes for a journalled second version: when the kept sequence does not hold the journalled SHA-256 (nothing was filed) the frame leaves `SecondVersions` and `VersionShas` and is verified as on a first visit, which files the bytes it reads now; when it holds them, they are left out of Main and the merge stops with "changed" and drops its journal, so the next run plans again (#73) | Treat the new bytes as another second version in the same run | A stop that kept the journal failed the same way on every retry once the file changed (an editor saving, a sync tool, an edit before a retry after a failed copy), and a cancel then left a filed version in Main; filing a third version unplanned goes further than the plan the user confirmed, while a new plan compares the new bytes and shows them |
|
||||
+2
-2
@@ -20,7 +20,7 @@ by its `windows` job once a Windows runner is registered (`WINDOWS_RUNNER`), and
|
||||
| 8.4 Owner review 4 | Done (request and plan: `docs/requests/2026-11-06-owner-review-4.md`): released as `v0.1.0-rc.14` with owner review 1 phase 6 (the deploy guide `docs/deploy/`), then as `v1.0.0` (#23), the first stable release: R1 work board of every video made or published, the published apart from workspace work (#29); R2 the anonymous usage counts removed, nothing sent by itself (#30); R3 the archive's whole folder structure created inside the chosen archive path, desktop and server (#31); R4 the repository on Gitea in order (earlier work as closed issues #32–#54 in their milestones, the original documentation in `docs/reference/original`, `fe50b877`); R5 licensing set aside and recorded in #24. |
|
||||
| 8.5 Owner review 5 | Done (request, answers and plan: `docs/requests/2026-11-15-owner-review-5.md`; issues #64–#67, milestone v1.1.0), released as `v1.1.0`: one setup for Chronos Desktop and Chronos Uploader with the Uploader's update check (#64); the detail of mass passes (step, photo x of y, sequence n of m, rate, time left) on the desktop, the admin panel and, for the connected server's jobs, the desktop's Server section (#65); separate homes per server keyed by a stable server id, with the 1.0 workspace and cache sorted at the first start and a separate originals archive per server (#66); Chronos Desktop sharing its library on the LAN in place of Chronos Server for Windows, running on in the tray while it shares (#67). One review round, 15 findings fixed; strings in all 38 languages. Not run on the PC: the Windows-only smoke tests, `installer-test.ps1` and the release dry run (CI runs them). Follow-ups: a firewall status row, Change…/Forget on known servers, the LAN beacon announcing the server id, docs/ui DESIGN and mockups for the new screens. |
|
||||
| 8.6 Windows test of 1.1.0 | Done (#70, milestone v1.1.1), released as `v1.1.1`: the App and Core.Windows suites run whole on the development PC (5 stale screen tests brought up to date); a hands-on test of a portable 1.1.0 (import, Reorganize, sharing, a client, tray, Exit with clients); fixes: job log times in local time, the Jobs Type column, Forget in Bulgarian, the Reorganize capture. Still to do by the owner: the real 1.0 → 1.1 upgrade on this PC (UAC). |
|
||||
| 8.7 Owner review 6 | In progress (request, answers and plan: `docs/requests/2026-11-16-owner-review-6.md`; #73, milestone v1.2.0), implemented on `or6-duplicates`, not released: matches, the same time-lapse on a server and on this PC under different ids or twice on this PC, found after each sync refresh (the server's new photo lookup) and after jobs that change photos (migration 0012, `Chronos.Data.Copies`); Server › Matches with Keep apart, Link only, Unlink and the Compare dialog (Photos, Details line by line, Projects, Plan); Integrate of a local and a server sequence (job 25: photos both ways under Union by default, details as one change, projects copied across, losers to the trash only after a hash check) and the merge of two local sequences (job 26: the other to its archive's trash once every photo is verified); new photos of integrated pairs moved by themselves, *deleted there* and *deleted on server* reviewed by the user; Settings › Server › Link matches (Ask always), Integrate photos (Union), Integrate projects (Copy across); Upload all local skips suspected matches. Eight parcels, one review round (correctness, safety, conformance) with every verified finding fixed, a gap round and six verification rounds; the strings in all 38 languages, the match terms in every language's glossary; the Windows captures of the new screens are committed as screenshot baselines (`server-copies-*`, `library-copies-*`, `server-sync-copyfound-*`, `edit-picker-twins-*`); the photos a sequence keeps in two versions are listed with Drop… from the Library (Two versions…) and a merge job's Open. Still to do: the PostgreSQL tests in CI, the release. Follow-ups: a field-level merge of an integrated pair's settings (to ask the owner), the Import › Folder… warning, the same two-versions list in Edit, a capture scene of the Two versions… dialog. |
|
||||
| 8.7 Owner review 6 | Done (request, answers and plan: `docs/requests/2026-11-16-owner-review-6.md`; #73, milestone v1.2.0), released as `v1.2.0`: matches, the same time-lapse on a server and on this PC under different ids or twice on this PC, found after each sync refresh (the server's new photo lookup) and after jobs that change photos (migration 0012, `Chronos.Data.Copies`); Server › Matches with Keep apart, Link only, Unlink and the Compare dialog (Photos, Details line by line, Projects, Plan); Integrate of a local and a server sequence (job 25: photos both ways under Union by default, details as one change, projects copied across, losers to the trash only after a hash check) and the merge of two local sequences (job 26: the other to its archive's trash once every photo is verified); new photos of integrated pairs moved by themselves, *deleted there* and *deleted on server* reviewed by the user; Settings › Server › Link matches (Ask always), Integrate photos (Union), Integrate projects (Copy across); Upload all local skips suspected matches. Eight parcels, one review round (correctness, safety, conformance) with every verified finding fixed, a gap round and twelve verification rounds (the last seven on the data engines only, with three-vote confirmation, until one found nothing); the strings in all 38 languages, the match terms in every language's glossary; the Windows captures of the new screens are committed as screenshot baselines (`server-copies-*`, `library-copies-*`, `server-sync-copyfound-*`, `edit-picker-twins-*`); the photos a sequence keeps in two versions are listed with Drop… from the Library (Two versions…) and a merge job's Open. Follow-ups: a field-level merge of an integrated pair's settings (to ask the owner), the Import › Folder… warning, the same two-versions list in Edit, a capture scene of the Two versions… dialog. |
|
||||
| 9 Monetization | Not started: requires explicit approval (§22); the proposal is recorded in issue #24 (owner review 4, R5). |
|
||||
|
||||
## Verification (2026-10-12)
|
||||
@@ -69,7 +69,7 @@ src/Chronos.App/bin/Release/net10.0-windows/Chronos.exe --capture out/screenshot
|
||||
- Job log time (1.1.1): Jobs › expand a job: the log times match the row times (local).
|
||||
- Share this library: Settings › Server › *Share this library*, then Server › This library; connect the Uploader or
|
||||
another PC to the address shown.
|
||||
- Owner review 6 (v1.2.0, in progress): send a folder of photos to a 1.2 server with Chronos Uploader; on the desktop
|
||||
- Owner review 6 (v1.2.0): send a folder of photos to a 1.2 server with Chronos Uploader; on the desktop
|
||||
import the same folder plus a few more photos (Import › *Folder…*), give it another title and sign in. After the
|
||||
refresh Server › *Matches* lists it as *match found*; *Compare…* shows the photos only here and the differing title;
|
||||
*Integrate…* opens on Details: *All this PC*, then *Integrate*. The row reads *integrating · x of y*, then
|
||||
|
||||
@@ -67,10 +67,10 @@ local folders and *Upload all local*). The owner answered in Italian; quoted wor
|
||||
|
||||
| Phase | Content | State | Commit |
|
||||
|---|---|---|---|
|
||||
| 1 | `v1.2.0`: R1–R7 (#73); R8 tracking. Parcels: P0 foundation (contracts, migration 0012, store, wire, trash and job hooks, keys), P1a pure comparison and rules, P1b detection and sync integration, P2 server photo lookup and uploads into a target, P3 Integrate, P4 merge of two local sequences, P5 engine composition and automatic photos, P6 the desktop surfaces; then one review round (correctness, safety, conformance) with every verified finding fixed, a gap round and six verification rounds. BRIEF §5, §6.2, §12.2, §12.3, §12.5, §12.7, §12.8, §14.3, §14.4, §14.5, §14.6, §24 and Appendix C amended; DESIGN §4 *Matches*; DECISIONS rows dated 2026-11-16 and 2026-11-17 citing #73 | in progress: implemented on `or6-duplicates`, not released; strings in all 38 languages and their glossaries; the Windows captures committed as baselines; the PostgreSQL tests in CI still to run | `283d04d9` … `38764972`, then the documentation pass |
|
||||
| 1 | `v1.2.0`: R1–R7 (#73); R8 tracking. Parcels: P0 foundation (contracts, migration 0012, store, wire, trash and job hooks, keys), P1a pure comparison and rules, P1b detection and sync integration, P2 server photo lookup and uploads into a target, P3 Integrate, P4 merge of two local sequences, P5 engine composition and automatic photos, P6 the desktop surfaces; then one review round (correctness, safety, conformance) with every verified finding fixed, a gap round and twelve verification rounds (the last seven on the data engines only, each finding confirmed by two of three independent checks, the last three on the latest fixes only, until one found nothing). BRIEF §5, §6.2, §12.2, §12.3, §12.5, §12.7, §12.8, §14.3, §14.4, §14.5, §14.6, §24 and Appendix C amended; DESIGN §4 *Matches*; DECISIONS rows dated 2026-11-16 to 2026-11-18 citing #73 | done: released as `v1.2.0` on 2026-11-18; strings in all 38 languages and their glossaries; the Windows captures committed as baselines; CI green with PostgreSQL 16 and 17 | `283d04d9` … `65b7cdf9` on `or6-duplicates`, squash-merged into `main` |
|
||||
|
||||
Follow-ups kept out of 1.2.0: a field-level three-way merge of an integrated pair's settings (settings sync as today,
|
||||
owner Q6; to be asked of the owner), the Import › Folder… warning for photos already on a server, merging two
|
||||
sequences of one server, the list of second versions with *Drop…* in Edit (the Library has it: *Two versions…*).
|
||||
|
||||
Tracking: issue #73, milestone `v1.2.0`, board card; status **in progress**.
|
||||
Tracking: issue #73, milestone `v1.2.0`, board card; status **done**.
|
||||
@@ -52,6 +52,12 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
/// <summary>Called before each stage runs (tests: a crash, a change made between stages).</summary>
|
||||
internal Func<MergeStage, Task>? BeforeStage { get; set; }
|
||||
|
||||
/// <summary>Called before a second version is left out of Main (tests: a failure between filing it and saving the journal).</summary>
|
||||
internal Func<string, Task>? BeforeLeaveOutOfMain { get; set; }
|
||||
|
||||
/// <summary>Called before the verify files a second version, once the journal names it (tests: its file rewritten meanwhile).</summary>
|
||||
internal Func<Guid, Task>? BeforeFileVersion { get; set; }
|
||||
|
||||
public async Task RunAsync(JobContext context)
|
||||
{
|
||||
var job = context.Job;
|
||||
@@ -395,6 +401,7 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
private async Task LeaveOutOfMainAsync(string sha)
|
||||
{
|
||||
var ct = CancellationToken.None;
|
||||
if (owner.BeforeLeaveOutOfMain is { } hook) await hook(sha).ConfigureAwait(false);
|
||||
for (var attempt = 1; ; attempt++)
|
||||
{
|
||||
var keep = await _db.Sequences.GetAsync(journal.KeepId, ct).ConfigureAwait(false) ?? throw new StaleCopyPlanException();
|
||||
@@ -655,9 +662,35 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
?? throw new InvalidOperationException(Loc.L("Errors.Copies.ChangedFile", frame.FileName));
|
||||
if (frame.Sha256 is { Length: > 0 } recorded && !string.Equals(recorded, sha, StringComparison.OrdinalIgnoreCase))
|
||||
throw new InvalidOperationException(Loc.L("Errors.Copies.ChangedFile", frame.FileName));
|
||||
var version = journal.SecondVersions.Contains(frame.Id);
|
||||
if (version && journal.VersionShas.GetValueOrDefault(frame.Id) is var filedAs
|
||||
&& !string.Equals(filedAs, sha, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// A run that stopped while filing it as a second version read other bytes: changed since.
|
||||
if (filedAs is null || !held.ContainsKey(filedAs))
|
||||
{
|
||||
// Nothing was filed (the copy failed or read other bytes): visited as for the first time.
|
||||
journal.SecondVersions.Remove(frame.Id);
|
||||
journal.VersionShas.Remove(frame.Id);
|
||||
Save();
|
||||
version = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The old bytes were filed: left out of Main now (a new plan reads them as the kept sequence's
|
||||
// own photo), then the merge stops and is planned again, which compares the new bytes.
|
||||
await LeaveOutOfMainAsync(filedAs).ConfigureAwait(false);
|
||||
ForgetJournal();
|
||||
throw new InvalidOperationException(Loc.L("Errors.Copies.ChangedFile", frame.FileName));
|
||||
}
|
||||
}
|
||||
if (held.TryGetValue(sha, out var keepFrame))
|
||||
{
|
||||
// Filed as a second version by a run that stopped before the journal said so: left out of Main again
|
||||
// (nothing changes when it already is), and still left out at the Details stage.
|
||||
if (version) await LeaveOutOfMainAsync(sha).ConfigureAwait(false);
|
||||
journal.Verified[frame.Id] = new MergeVerified(sha, keepFrame);
|
||||
if (version) Save();
|
||||
continue;
|
||||
}
|
||||
if (journal.Absent.Contains(sha))
|
||||
@@ -669,9 +702,14 @@ internal sealed class MergeJobHandler(ChronosDatabase db, SequenceMerger merger,
|
||||
if (frame.Sha256 is not { Length: > 0 } && !keepRemoved.Contains(sha))
|
||||
{
|
||||
// Compared by size and time only, and another photo after all: filed in the kept sequence as a second version.
|
||||
// The journal says so before it is filed: a run that stops before it is left out of Main (the exclusion
|
||||
// fails, the app ends) finds it in the kept sequence on resume and leaves it out then.
|
||||
if (!version) journal.SecondVersions.Add(frame.Id);
|
||||
journal.VersionShas[frame.Id] = sha.ToLowerInvariant();
|
||||
Save();
|
||||
if (owner.BeforeFileVersion is { } fileHook) await fileHook(frame.Id).ConfigureAwait(false);
|
||||
var filed = await FileAsync(frame, sha, planned: false).ConfigureAwait(false);
|
||||
await LeaveOutOfMainAsync(sha).ConfigureAwait(false);
|
||||
journal.SecondVersions.Add(frame.Id);
|
||||
journal.Verified[frame.Id] = new MergeVerified(sha, filed.FrameId);
|
||||
held.TryAdd(sha, filed.FrameId);
|
||||
Save();
|
||||
|
||||
@@ -105,6 +105,14 @@ internal sealed class MergeJournal
|
||||
/// <summary>Drop frames the verify found to be another photo than keep's (unhashed, same size and time) and filed as a second version.</summary>
|
||||
public List<Guid> SecondVersions { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Drop frame of <see cref="SecondVersions"/> → the SHA-256 it is filed as, written before it is filed: a resumed verify
|
||||
/// that finds it in the kept sequence leaves it out of Main again. One that reads other bytes starts over for that frame
|
||||
/// when the kept sequence does not hold the old ones (nothing was filed), else leaves them out of Main and stops, and the
|
||||
/// merge is planned again.
|
||||
/// </summary>
|
||||
public Dictionary<Guid, string> VersionShas { get; set; } = [];
|
||||
|
||||
/// <summary>Drop frames the verify found nothing of to lose: last copies the plan listed, or photos a third sequence holds.</summary>
|
||||
public List<Guid> Settled { get; set; } = [];
|
||||
|
||||
|
||||
@@ -55,10 +55,10 @@ public static class UploadAllRule
|
||||
foreach (var entry in localOnly)
|
||||
{
|
||||
if (entry.Local is not { } local) continue;
|
||||
// A Kept apart answer about a server sequence confirmed deleted there (two 404s apart) holds nothing back: that
|
||||
// sequence is no copy of anything any more, and the local one is this PC's only.
|
||||
var pairs = (bySequence.GetValueOrDefault(local.Id) ?? []).Where(p => p is not { Kind: CopyKind.LocalServer, State: CopyState.KeptApart, RemoteGone: true })
|
||||
.ToList();
|
||||
// A Kept apart answer given before a server sequence was confirmed deleted there (two 404s apart) holds nothing
|
||||
// back: that sequence is no copy of anything any more, and the local one is this PC's only. A Keep here, answered
|
||||
// once the deletion was shown, is the user's answer about the deletion itself: it still skips.
|
||||
var pairs = (bySequence.GetValueOrDefault(local.Id) ?? []).Where(p => !ApartBeforeDeletion(p)).ToList();
|
||||
UploadSkip? why =
|
||||
busy.Contains(local.Id) || pairs.Any(p => p.State == CopyState.Integrating) ? UploadSkip.Busy
|
||||
: pairs.Any(p => p.Kind == CopyKind.LocalServer && p.RemoteGoneHits >= 1) ? UploadSkip.DeletedOnServer
|
||||
@@ -71,6 +71,10 @@ public static class UploadAllRule
|
||||
}
|
||||
return (upload, skipped);
|
||||
|
||||
static bool ApartBeforeDeletion(FoundCopy p) =>
|
||||
p is { Kind: CopyKind.LocalServer, State: CopyState.KeptApart, RemoteGone: true, AnsweredAt: { } answered, RemoteGoneAt: { } gone }
|
||||
&& answered < gone;
|
||||
|
||||
void Add(Guid id, FoundCopy copy)
|
||||
{
|
||||
if (!bySequence.TryGetValue(id, out var list)) bySequence[id] = list = [];
|
||||
|
||||
@@ -37,6 +37,9 @@ internal sealed class SyncTransfers(SyncService sync)
|
||||
{
|
||||
private const long SpaceReserve = 512L << 20;
|
||||
|
||||
/// <summary>The upload checkpoint's suffix for a server sequence the job joined (one this PC already knew), not made.</summary>
|
||||
private const string JoinedMark = ":joined";
|
||||
|
||||
/// <summary>Space a cached proxy is assumed to take before it is downloaded (1920 px JPEG, BRIEF §8.5).</summary>
|
||||
private const long ProxyEstimate = 3L << 19;
|
||||
|
||||
@@ -94,7 +97,9 @@ internal sealed class SyncTransfers(SyncService sync)
|
||||
{
|
||||
remoteId = sent.SequenceId;
|
||||
if (knownRemotes.Contains(sent.SequenceId)) created = false;
|
||||
await context.CheckpointAsync(sent.SequenceId.ToString(), progress.Done + 1, frames.Count).ConfigureAwait(false);
|
||||
// Saved with the target: a resumed or retried attempt reads whether this job made it, never infers it.
|
||||
await context.CheckpointAsync(sent.SequenceId.ToString() + (created ? string.Empty : JoinedMark), progress.Done + 1, frames.Count)
|
||||
.ConfigureAwait(false);
|
||||
await sync.LinkAsync(remote.Server, sent.SequenceId, local, ct).ConfigureAwait(false);
|
||||
}
|
||||
await progress.StepAsync().ConfigureAwait(false);
|
||||
@@ -962,11 +967,15 @@ internal sealed class SyncTransfers(SyncService sync)
|
||||
/// <summary>
|
||||
/// The server sequence an upload fills and whether this job creates it: the linked one, the one an interrupted
|
||||
/// attempt created (unless the user kept it apart or unlinked it since), or none yet (the first original creates it).
|
||||
/// The checkpoint names the server sequence an earlier attempt reached, with <see cref="JoinedMark"/> when that attempt
|
||||
/// joined one this PC already knew (its details are compared, never sent all over the server's, on every attempt).
|
||||
/// </summary>
|
||||
private async Task<(Guid? RemoteId, bool Created)> TargetAsync(JobContext context, ISyncRemote remote, Sequence local)
|
||||
{
|
||||
var ct = context.Cancellation;
|
||||
Guid? started = Guid.TryParse(context.Checkpoint, out var saved) ? saved : null;
|
||||
var checkpoint = context.Checkpoint ?? string.Empty;
|
||||
var joined = checkpoint.EndsWith(JoinedMark, StringComparison.Ordinal);
|
||||
Guid? started = Guid.TryParse(joined ? checkpoint[..^JoinedMark.Length] : checkpoint, out var saved) ? saved : null;
|
||||
var link = await sync.Links.FindByLocalAsync(remote.Server, local.Id, ct).ConfigureAwait(false);
|
||||
foreach (var candidate in new[] { link?.RemoteId, started })
|
||||
{
|
||||
@@ -978,7 +987,7 @@ internal sealed class SyncTransfers(SyncService sync)
|
||||
if (await ExistsAsync(remote, id, ct).ConfigureAwait(false))
|
||||
{
|
||||
if (link?.RemoteId != id) await sync.LinkAsync(remote.Server, id, local, ct).ConfigureAwait(false);
|
||||
return (id, id == started);
|
||||
return (id, id == started && !joined);
|
||||
}
|
||||
// Deleted on the server meanwhile: the originals go into a new sequence.
|
||||
if (id == link?.RemoteId) await sync.ForgetGoneAsync(remote.Server, id, ct).ConfigureAwait(false);
|
||||
|
||||
@@ -599,6 +599,116 @@ public abstract class SequenceMergerTests(TestContext context) : DatabaseTest(co
|
||||
AssertVersions(await new CopySides(fx.Db).VersionsAsync(keep.Id, Ct), Sha(mine, 0), Sha(theirs, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AVersionTheVerifyFiledBeforeTheRunStoppedIsLeftOutOfMainOnResume()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var (mine, theirs) = EqualSizeSeeds(0);
|
||||
var keep = await SequenceAsync(fx, "keep", [(mine, 0, "IMG_0001.JPG")]);
|
||||
var drop = await SequenceAsync(fx, "drop", [(theirs, 0, "IMG_0001.JPG")]);
|
||||
await new DbAccess(fx.Db.Database).ExecuteAsync("UPDATE frames SET sha256 = NULL WHERE sequence_id = $1 OR sequence_id = $2", [keep.Id, drop.Id], Ct);
|
||||
var copy = await PairAsync(fx, keep.Id, drop.Id);
|
||||
var merger = Merger(fx);
|
||||
var (engine, handler) = Engine(fx, merger, new FakeProjects(), new FakeWorkspace());
|
||||
await engine.StartAsync(Ct);
|
||||
// Filed at the verify, then the exclusion fails (a drive drops out, project.json is held) before the journal says so.
|
||||
var failedOnce = false;
|
||||
handler.BeforeLeaveOutOfMain = _ =>
|
||||
{
|
||||
if (failedOnce) return Task.CompletedTask;
|
||||
failedOnce = true;
|
||||
throw new IOException("project.json is in use");
|
||||
};
|
||||
var plan = await merger.PlanAsync(copy.Id, keep.Id, drop.Id, await ChoicesAsync(fx, keep.Id, drop.Id, CopyPhotoPolicy.Union), NoContext, Ct);
|
||||
Assert.Empty(plan.Photos);
|
||||
var job = await merger.EnqueueAsync(engine, new FoundCopyStore(fx.Db), plan, keep.DisplayTitle, Ct);
|
||||
await fx.WaitForAsync(job.Id, JobState.Failed);
|
||||
Assert.True((await HashesAsync(fx, keep.Id)).SetEquals([Sha(mine, 0), Sha(theirs, 0)]));
|
||||
|
||||
await engine.ResumeAsync(job.Id, Ct);
|
||||
await fx.WaitForAsync(job.Id, JobState.Done);
|
||||
|
||||
// The resumed verify finds the version in the kept sequence and leaves it out of Main: one photo at that instant.
|
||||
Assert.Null(await fx.Db.Sequences.GetAsync(drop.Id));
|
||||
AssertVersions(await new CopySides(fx.Db).VersionsAsync(keep.Id, Ct), Sha(mine, 0), Sha(theirs, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AVersionWhoseFileChangedBeforeItWasFiledIsFiledAsItIsOnResume()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var (mine, theirs) = EqualSizeSeeds(0);
|
||||
var edited = EqualSizeSeed(0, theirs, mine);
|
||||
var keep = await SequenceAsync(fx, "keep", [(mine, 0, "IMG_0001.JPG")]);
|
||||
var drop = await SequenceAsync(fx, "drop", [(theirs, 0, "IMG_0001.JPG")]);
|
||||
await new DbAccess(fx.Db.Database).ExecuteAsync("UPDATE frames SET sha256 = NULL WHERE sequence_id = $1 OR sequence_id = $2", [keep.Id, drop.Id], Ct);
|
||||
var path = fx.Paths.FromRelative((await fx.Db.Frames.ListBySequenceAsync(drop.Id)).Single().RelativePath);
|
||||
var copy = await PairAsync(fx, keep.Id, drop.Id);
|
||||
var merger = Merger(fx);
|
||||
var (engine, handler) = Engine(fx, merger, new FakeProjects(), new FakeWorkspace());
|
||||
await engine.StartAsync(Ct);
|
||||
// The file is rewritten (an editor saving a rotation) between its hash and its copy: the copy reads other bytes.
|
||||
var rewritten = false;
|
||||
handler.BeforeFileVersion = _ =>
|
||||
{
|
||||
if (rewritten) return Task.CompletedTask;
|
||||
rewritten = true;
|
||||
File.WriteAllBytes(path, Photos.Jpeg(Start, edited));
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
var plan = await merger.PlanAsync(copy.Id, keep.Id, drop.Id, await ChoicesAsync(fx, keep.Id, drop.Id, CopyPhotoPolicy.Union), NoContext, Ct);
|
||||
var job = await merger.EnqueueAsync(engine, new FoundCopyStore(fx.Db), plan, keep.DisplayTitle, Ct);
|
||||
await fx.WaitForAsync(job.Id, JobState.Failed);
|
||||
Assert.True((await HashesAsync(fx, keep.Id)).SetEquals([Sha(mine, 0)]), "nothing was filed");
|
||||
|
||||
await engine.ResumeAsync(job.Id, Ct);
|
||||
await fx.WaitForAsync(job.Id, JobState.Done);
|
||||
|
||||
// Nothing was filed: the retry files the photo as it is now, as a second version left out of Main.
|
||||
Assert.Null(await fx.Db.Sequences.GetAsync(drop.Id));
|
||||
Assert.True((await HashesAsync(fx, keep.Id)).SetEquals([Sha(mine, 0), Sha(edited, 0)]));
|
||||
AssertVersions(await new CopySides(fx.Db).VersionsAsync(keep.Id, Ct), Sha(mine, 0), Sha(edited, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AVersionFiledBeforeItsFileChangedIsLeftOutOfMainAndTheMergePlannedAgain()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var (mine, theirs) = EqualSizeSeeds(0);
|
||||
var edited = EqualSizeSeed(0, theirs, mine);
|
||||
var keep = await SequenceAsync(fx, "keep", [(mine, 0, "IMG_0001.JPG")]);
|
||||
var drop = await SequenceAsync(fx, "drop", [(theirs, 0, "IMG_0001.JPG")]);
|
||||
await new DbAccess(fx.Db.Database).ExecuteAsync("UPDATE frames SET sha256 = NULL WHERE sequence_id = $1 OR sequence_id = $2", [keep.Id, drop.Id], Ct);
|
||||
var dropFrame = (await fx.Db.Frames.ListBySequenceAsync(drop.Id)).Single();
|
||||
var path = fx.Paths.FromRelative(dropFrame.RelativePath);
|
||||
var copy = await PairAsync(fx, keep.Id, drop.Id);
|
||||
var merger = Merger(fx);
|
||||
var (engine, handler) = Engine(fx, merger, new FakeProjects(), new FakeWorkspace());
|
||||
await engine.StartAsync(Ct);
|
||||
// Filed at the verify, then the exclusion fails; the file is rewritten before the retry.
|
||||
var failedOnce = false;
|
||||
handler.BeforeLeaveOutOfMain = _ =>
|
||||
{
|
||||
if (failedOnce) return Task.CompletedTask;
|
||||
failedOnce = true;
|
||||
File.WriteAllBytes(path, Photos.Jpeg(Start, edited));
|
||||
throw new IOException("project.json is in use");
|
||||
};
|
||||
var plan = await merger.PlanAsync(copy.Id, keep.Id, drop.Id, await ChoicesAsync(fx, keep.Id, drop.Id, CopyPhotoPolicy.Union), NoContext, Ct);
|
||||
var job = await merger.EnqueueAsync(engine, new FoundCopyStore(fx.Db), plan, keep.DisplayTitle, Ct);
|
||||
await fx.WaitForAsync(job.Id, JobState.Failed);
|
||||
Assert.True((await HashesAsync(fx, keep.Id)).SetEquals([Sha(mine, 0), Sha(theirs, 0)]));
|
||||
|
||||
await engine.ResumeAsync(job.Id, Ct);
|
||||
var failed = await fx.WaitForAsync(job.Id, JobState.Failed);
|
||||
|
||||
// The filed version is left out of Main, the other stays, and the journal goes: the next run plans again.
|
||||
Assert.Equal(Chronos.Core.Localization.Loc.L("Errors.Copies.ChangedFile", dropFrame.FileName), failed.Error);
|
||||
Assert.NotNull(await fx.Db.Sequences.GetAsync(drop.Id));
|
||||
AssertVersions(await new CopySides(fx.Db).VersionsAsync(keep.Id, Ct), Sha(mine, 0), Sha(theirs, 0));
|
||||
Assert.False(File.Exists(MergeJournal.PathFor(fx.Paths, job.Id)), "the next run plans again");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASecondVersionCopiedInByAMergeAbandonedBeforeItsDetailsStaysOutOfMain()
|
||||
{
|
||||
@@ -709,6 +819,14 @@ public abstract class SequenceMergerTests(TestContext context) : DatabaseTest(co
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A seed other than <paramref name="like"/> and <paramref name="not"/> whose photo at <paramref name="ms"/> has the same size as <paramref name="like"/>'s.</summary>
|
||||
private static int EqualSizeSeed(int ms, int like, params int[] not)
|
||||
{
|
||||
var length = Photos.Jpeg(Start.AddMilliseconds(ms), like).Length;
|
||||
for (var seed = 1; ; seed++)
|
||||
if (seed != like && !not.Contains(seed) && Photos.Jpeg(Start.AddMilliseconds(ms), seed).Length == length) return seed;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnUnhashedPhotoOfTheKeptOneWithTheSameContentIsNoLastCopy()
|
||||
{
|
||||
|
||||
@@ -183,6 +183,30 @@ public sealed class CopyEngineTests(TestContext context)
|
||||
Assert.NotNull(await f.Sync.Links.GetAsync(f.Server, remote.Id, f.Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task KeepHereOfASequenceDeletedOnTheServerIsLeftOutOfUploadAllLocal()
|
||||
{
|
||||
await using var f = await FixtureAsync(context);
|
||||
var local = await f.LocalAsync("Comet", f.NewPhotos(2));
|
||||
var gone = Guid.CreateVersion7();
|
||||
var pair = await f.Sync.Copies.EnsureLinkedAsync(f.Server, gone, local.Id, f.Ct);
|
||||
// Deleted on the server: two 404s the re-check apart, read as deleted on server.
|
||||
var at = DateTimeOffset.UtcNow.AddHours(-2);
|
||||
await f.Sync.Copies.MarkRemoteGoneAsync(f.Server, gone, local.Id, Guid.NewGuid(), at, f.Ct);
|
||||
await f.Sync.Copies.MarkRemoteGoneAsync(f.Server, gone, local.Id, Guid.NewGuid(), at.AddHours(1), f.Ct);
|
||||
using var engine = Engine(f);
|
||||
|
||||
await engine.KeepHereAsync(pair.Id, f.Ct);
|
||||
|
||||
// Kept here: Upload all local leaves it out, and the answer stays.
|
||||
var row = (await f.Sync.Copies.GetAsync(pair.Id, f.Ct))!;
|
||||
Assert.Equal((CopyState.KeptApart, true), (row.State, row.RemoteGone));
|
||||
var entry = new SyncEntry(local, null, SyncStatus.LocalOnly);
|
||||
var (upload, skipped) = UploadAllRule.Select([entry], await f.Sync.Copies.ListAsync(f.Ct), new HashSet<Guid>(), new HashSet<Guid>());
|
||||
Assert.Empty(upload);
|
||||
Assert.Equal(local.Id, skipped.Single().Entry.Local!.Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task LinkIsRefusedWhenTheLocalCopyIsLinkedToAnotherServerSequence()
|
||||
{
|
||||
|
||||
@@ -288,10 +288,10 @@ public abstract class FoundCopyStoreTests(TestContext context) : RepositoryTest(
|
||||
Assert.True(await store.SetStateAsync(linked.Id, CopyState.Candidate, CopyState.Linked, Answer(), Ct));
|
||||
var elsewhere = await store.UpsertFoundAsync(Remote(s[3].Id, Guid.CreateVersion7()), Ct);
|
||||
|
||||
// An observation-only link answers 404: no local copy is linked to it.
|
||||
// After the answers, an observation-only link answers 404: no local copy is linked to it.
|
||||
var first = Guid.NewGuid();
|
||||
await store.MarkRemoteGoneAsync(Nas, remote, null, first, TestData.Now, Ct);
|
||||
await store.MarkRemoteGoneAsync(Nas, remote, null, first, TestData.Now.AddMinutes(1), Ct);
|
||||
await store.MarkRemoteGoneAsync(Nas, remote, null, first, TestData.Now.AddMinutes(2), Ct);
|
||||
|
||||
// The unanswered match is gone; the Keep apart answer stays and counts the 404 once, not read as deleted yet.
|
||||
Assert.Null(await store.GetAsync(candidate.Id, Ct));
|
||||
|
||||
@@ -394,6 +394,62 @@ public sealed class SyncTransferCopyTests(TestContext context)
|
||||
Assert.Equal("Comet", (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!.Title);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ARetriedUploadThatJoinedAServerSequenceItKnewStillComparesItsDetails()
|
||||
{
|
||||
await using var f = Capable(await SyncFixture.CreateAsync(context));
|
||||
var photos = f.NewPhotos(4);
|
||||
var local = await f.LocalAsync("Comet", [photos[0], photos[1]]);
|
||||
var engine = await f.StartEngineAsync();
|
||||
var job = await f.Sync.EnqueueUploadAsync(engine, f.Server, local);
|
||||
await f.Archive.WaitForAsync(job.Id, JobState.Done);
|
||||
var first = Assert.NotNull(await f.Sync.Links.FindByLocalAsync(f.Server, local.Id, f.Ct)).RemoteId;
|
||||
// The link and its pair were forgotten; the server sequence is listed again and renamed there.
|
||||
var observed = Assert.NotNull(await f.Sync.Links.GetAsync(f.Server, first, f.Ct)) with { LocalId = null };
|
||||
await f.Sync.Links.UpsertAsync(observed, f.Ct);
|
||||
await using (var session = await f.Db.Database.OpenAsync(f.Ct))
|
||||
await session.ExecuteAsync("DELETE FROM found_copies WHERE remote_id = $1", [first], f.Ct);
|
||||
var server = f.Remote.Sequences[first];
|
||||
server.Title = "Comet NAS";
|
||||
server.SettingsVersion++;
|
||||
server.UpdatedAt = DateTimeOffset.UtcNow;
|
||||
await f.AddLocalAsync(local.Id, photos[2]);
|
||||
await f.AddLocalAsync(local.Id, photos[3]);
|
||||
// One original unreadable for the first attempt: it fails after joining the known sequence.
|
||||
var damaged = (await f.Db.Frames.ListBySequenceAsync(local.Id, cancellationToken: f.Ct)).Single(fr => fr.Sha256 == Sha(photos[3]));
|
||||
var path = f.Archive.Paths.FromRelative(damaged.RelativePath);
|
||||
var bytes = await File.ReadAllBytesAsync(path, f.Ct);
|
||||
var broken = bytes.ToArray();
|
||||
broken[^3] ^= 0xFF;
|
||||
await File.WriteAllBytesAsync(path, broken, f.Ct);
|
||||
|
||||
var row = new Job
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
Kind = JobKind.UploadCommit,
|
||||
TargetIds = [local.Id],
|
||||
State = JobState.Running,
|
||||
NodeId = "t#0",
|
||||
Created = DateTimeOffset.UtcNow,
|
||||
Started = DateTimeOffset.UtcNow,
|
||||
};
|
||||
await f.Db.Jobs.EnqueueAsync(row, f.Ct);
|
||||
var jobs = new JobEngine(f.Db, [], new JobEngineOptions { WorkerId = "t" });
|
||||
var attempt = new JobContext(jobs, row, f.Ct);
|
||||
await Assert.ThrowsAsync<InvalidDataException>(() => new SyncTransfers(f.Sync).UploadAsync(attempt, f.Remote, local.Id));
|
||||
Assert.Equal(first, Assert.NotNull(await f.Sync.Links.FindByLocalAsync(f.Server, local.Id, f.Ct)).RemoteId);
|
||||
|
||||
// Retried from that attempt's checkpoint, the original readable again.
|
||||
await File.WriteAllBytesAsync(path, bytes, f.Ct);
|
||||
var retry = new JobContext(jobs, row with { Checkpoint = attempt.Checkpoint }, f.Ct);
|
||||
await new SyncTransfers(f.Sync).UploadAsync(retry, f.Remote, local.Id);
|
||||
|
||||
// Still joined, not made by this upload: the server's title is not overwritten unseen.
|
||||
Assert.True(server.Frames.Select(fr => fr.Sha256).ToHashSet().SetEquals(photos.Select(Sha)));
|
||||
Assert.Equal("Comet NAS", server.Title);
|
||||
Assert.Equal("Comet", (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!.Title);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnAutomaticUploadAfterTheServerCopyIsGoneFailsAndCreatesNothing()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user