Merge branch 'review2-p1-fix-import' into claude/owner-review-2-p1

This commit is contained in:
Alby96 committed 2026-10-26 23:40:39 +01:00
commit b8fa04dc28
13 files changed
+181 -25

No files matched your search

+4 -2
View File
@@ -815,8 +815,10 @@ player smoke test on Windows CI.
per file format: camera bodies and pauses are ignored, formats are not (RAW+JPEG of the
same shots stays two sequences, so no frame is doubled). Sessions, gap and minimum are
then disabled, their tooltips saying why. The title defaults to the folder's name (a
typed title wins; it also fills `{title}`). Each plan row shows the camera, or "n
cameras", and the format; Split in Show plan cuts a part off, Merge joins it back. A folder
typed title wins; it also fills `{title}`); a repeated import gives the folder's name
only to a sequence without a title, so a rename made since survives. Each plan row shows
the camera, or "n cameras", and the format, and both dates when its photos span several
days; Split in Show plan cuts a part off, Merge joins it back. A folder
starts on Sessions every time (folders have no profile); cards, drives and the admin
panel have no Group choice.
- Copy with hash while streaming; verify by re-reading destination; only then delete or
+3 -2
View File
@@ -8,8 +8,8 @@ commits follow Conventional Commits (release notes are generated from them by `C
### Added
- Import › Folder…: **Group › Whole folder** imports the picked folder, with its subfolders when Subfolders is on, as
one sequence per file format, whatever the cameras and pauses (RAW+JPEG stays two sequences). The title defaults to
the folder's name, and an interrupted or repeated import of the folder continues the same sequence. Desktop only
(owner review 2, R9).
the folder's name, and an interrupted or repeated import of the folder continues the same sequence without renaming
it. Desktop only (owner review 2, R9).
- Server: `CHRONOS_SPACE_PATH` (`SpacePath` in `server.json`) makes the admin panel show the free space of that
folder's volume instead of the archive's. The Unraid template maps the share's array view (`/mnt/user0/Timelapse`)
read-only to `/space` (*Array view*), so the dashboard shows the array's free space, not the cache's (owner review 2,
@@ -38,6 +38,7 @@ commits follow Conventional Commits (release notes are generated from them by `C
(owner review 2, R4).
### Fixed
- Import: a session that ends on another day shows both dates in its plan row and in Show plan, not only the first.
- Server: completing an upload, a render upload or a render node's result now checks the archive volume's free space
first. A full volume answers 507 `insufficient_storage` and the upload stays resumable, instead of the copy into
staging failing (owner review 2, R2).
+1 -1
View File
@@ -439,5 +439,5 @@ One line per decision: date · decision · alternative · reason.
| 2026-10-26 | Admin panel menu in two groups: Dashboard, Users, Archive, Jobs and Logs from the top; Settings docked at the sidebar's foot above the account, or at the end of the top bar on narrow screens; on a short window only the pages above scroll, so Settings and the account stay in view. `pages/about.js` is gone: About is the last, read-only group of Settings (version, API version, database, uptime counting on from when it was read; the last two fill in when the admin dashboard answers, so the form never waits for its archive statistics, and they stay off the anonymous `/server/info`), without the server name and certificate fingerprint rows that the Server and Network groups already show. `#/about` opens Settings on that group (focus on its heading) and rewrites the address to `#/settings`. (Owner review 2, R4, R5.) | Keep About as a page; an About dialog from the account box; repeat the name and fingerprint rows in About | One sidebar entry less, as the owner asked. Repeated rows on one page are noise, and the name row was stale after a save. Old bookmarks keep working. |
| 2026-10-26 | The Settings icon is an 8-tooth gear with a centre hole (outer radius 6.5, valleys on 4.6, teeth 0.6/0.85 half-width at tip/base, hole 1.7), drawn by `gear()` in `branding/ui-icons/icons.py`. The script now also writes the admin panel's `icons.js` (through a name map; the unused `about` icon dropped) and writes every file as UTF-8 with LF on every OS. (Owner review 2, R4.) | 6 teeth (crisper at 16 px but less familiar); wider hollow teeth (they merge at 16 px with 1.5 px strokes); radial stubs on a ring (close to the old sun); keep `icons.js` by hand | 8 narrow teeth close up into solid knobs at 16 px with open gaps, read as the usual settings gear at 20–32 px and stay distinct from Sun. One generator keeps the desktop and web paths identical. On Windows the script wrote `Icons.xaml` in the ANSI code page, garbling its header. |
| 2026-10-26 | Desktop About becomes the last Settings page (`SettingsPage.About`); `SectionKey.About` and `AboutView` are gone and the rail keeps Settings alone at the bottom. `AboutViewModel` (now `Chronos.App.About`) stays a view model owned by the shell (`Shell.About`), not a section, so the Updates page's bindings and the update check on start are unchanged. The page shows identity only (version, build, runtime, system, licence, third-party notice, translation notice outside English) and has no Reset section; the Releases link moved to Updates › Latest version; About's own diagnostics bundle and Open data folder buttons are removed (Advanced has both). (Owner review 2, R5.) | Move `UpdateFlow` into `SettingsViewModel`; embed the old AboutView inside Settings; repeat the data folder, diagnostics and update rows on About | Smallest change that keeps every `Shell.About` binding and the update check on start; one place per action avoids duplicates inside Settings, and saving space is what the owner asked for. Nothing navigated to the About section, so no link needed redirecting. |
| 2026-10-26 | Import › Folder… *Whole folder* (`ImportGrouping.WholeFolder`) makes one sequence per file format: camera bodies and pauses are ignored, formats are not; only the user's splits break it (the session splitter runs with no gap and a minimum of 1). The title defaults to the folder's name and fills `{title}`; a typed title wins. The plan row shows "Canon EOS R5 · CR3" or "2 cameras · JPEG", and a split part merges back into the part before it of the same format. Switching the grouping clears the user's splits and merges. (Owner review 2, R9.) | One sequence holding every file; one sequence per camera body | A folder shot RAW+JPEG would otherwise hold every instant twice, doubling the time-lapse; formats also decode and render differently. Bodies are ignored because the owner asked for the folder's sequence "in its entirety". |
| 2026-10-26 | Import › Folder… *Whole folder* (`ImportGrouping.WholeFolder`) makes one sequence per file format: camera bodies and pauses are ignored, formats are not; only the user's splits break it (the session splitter runs with no gap and a minimum of 1). The title defaults to the folder's name and fills `{title}`; a typed title wins. A repeated import gives the folder's name only to a sequence without a title: the archive applies a title only when it creates the sequence, and a server import reads the sequence first and names it only when it has none, so a rename made on the server survives (a typed title is still set). The plan row shows "Canon EOS R5 · CR3" or "2 cameras · JPEG", with both dates when the photos span several days, and a split part merges back into the part before it of the same format. Switching the grouping clears the user's splits and merges. (Owner review 2, R9.) | One sequence holding every file; one sequence per camera body | A folder shot RAW+JPEG would otherwise hold every instant twice, doubling the time-lapse; formats also decode and render differently. Bodies are ignored because the owner asked for the folder's sequence "in its entirety". |
| 2026-10-26 | A whole folder's session key is `folder-` + the first 16 hex digits of SHA-256 of "PC name, full path (trailing separator trimmed, upper-cased on Windows), format", plus `-yyyyMMdd-HHmmss` of the first photo for a part the user split off. The grouping is not stored in card profiles: a folder starts on Sessions, and cards and drives are always planned by sessions. (Owner review 2, R9.) | Hash of path and format only; remember the grouping per folder | The same key for the same folder lets an interrupted or repeated import continue its sequence through the existing session-key lookup. The server files client uploads by session key without user scope, so the same `D:\Photos\Trip` on two PCs must not land in one sequence; renaming the PC starts a new one (hash duplicate detection still prevents doubled frames). Folder sources have no profile today, so the simplest safe default applies. |
+2
View File
@@ -194,6 +194,8 @@
<data name="Import.Session.NewShort" xml:space="preserve"><value>new</value></data>
<data name="Import.Session.Server" xml:space="preserve"><value>Server</value></data>
<data name="Import.Session.Time" xml:space="preserve"><value>{0} · {1} → {2}</value><comment>invariant</comment></data>
<data name="Import.Session.TimeDays" xml:space="preserve"><value>{0} {1} → {2} {3}</value><comment>invariant</comment></data>
<data name="Import.Session.TimeDaysRtl" xml:space="preserve"><value>{0} {1} ← {2} {3}</value><comment>invariant</comment></data>
<data name="Import.Session.TimeRtl" xml:space="preserve"><value>{0} · {1} ← {2}</value><comment>invariant</comment></data>
<data name="Import.Session.TitleName" xml:space="preserve"><value>Sequence of session {0}</value></data>
<data name="Import.Start.one" xml:space="preserve"><value>Import {0:N0} photo</value></data>
+12 -6
View File
@@ -45,7 +45,10 @@ public sealed record PlanTotals(int Sessions, int Photos, int CopyCount, long Co
/// <param name="DefaultTitle">Title the sequence gets when the user types none (a whole folder's name, else its folder name).</param>
/// <param name="IsNew">The session starts a new sequence (false: it continues one imported before).</param>
/// <param name="FirstPath">Card path of the session's first photo (where a merge joins it to the previous session).</param>
/// <param name="MergesInto">Number of the earlier session of the same camera and format it can merge into; null for none.</param>
/// <param name="MergesInto">
/// Number of the earlier session it can merge into (same camera and format; for a whole folder, same format whatever the
/// camera); null for none.
/// </param>
public sealed record PlanSessionRow(int Number, string SessionKey, string? Title, string DefaultTitle, string TimeText, string FramesText,
string SizeText, string CameraText, string TargetText, bool IsNew, string FirstPath, int? MergesInto);
@@ -250,12 +253,15 @@ public static class ImportPlans
};
/// <summary>
/// "28/09/2026 · 18:02 → 20:04". Bidi never mirrors an arrow, so a right-to-left language reads it from its own
/// resource with the arrow pointing from the start to the end in its reading order.
/// "28/09/2026 · 18:02 → 20:04"; one that ends on another day (a whole folder, often) shows both dates:
/// "28/09/2026 18:02 → 06/10/2026 18:00". Bidi never mirrors an arrow, so a right-to-left language reads it from its
/// own resource with the arrow pointing from the start to the end in its reading order.
/// </summary>
private static string TimeText(PlannedSession s) =>
Loc.L(Loc.IsRightToLeft ? "Import.Session.TimeRtl" : "Import.Session.Time", Formatting.Date(s.Start), s.Start.ToString("t", Loc.Culture),
s.End.ToString("t", Loc.Culture));
private static string TimeText(PlannedSession s) => s.End.Date == s.Start.Date
? Loc.L(Loc.IsRightToLeft ? "Import.Session.TimeRtl" : "Import.Session.Time", Formatting.Date(s.Start), s.Start.ToString("t", Loc.Culture),
s.End.ToString("t", Loc.Culture))
: Loc.L(Loc.IsRightToLeft ? "Import.Session.TimeDaysRtl" : "Import.Session.TimeDays", Formatting.Date(s.Start), s.Start.ToString("t", Loc.Culture),
Formatting.Date(s.End), s.End.ToString("t", Loc.Culture));
/// <summary>"3,600 · 2 s": photos and the median interval between them.</summary>
private static string FramesText(PlannedSession s)
@@ -6,8 +6,9 @@ using Chronos.Ui.Mvvm;
namespace Chronos.App.Import;
/// <summary>
/// A session of the plan with its editable title (the sequence title; empty keeps the folder name) and its merge into
/// the earlier session of the same camera (BRIEF §13). Both can change only while the plan is not running.
/// A session of the plan with its editable title (the sequence title; empty keeps the default title) and its merge into
/// the earlier session of the same camera and format, or for a whole folder of the same format (BRIEF §13). Both can
/// change only while the plan is not running.
/// </summary>
public sealed class ImportSessionRowViewModel : ObservableObject
{
+12 -7
View File
@@ -13,10 +13,11 @@ namespace Chronos.App.Import;
/// protocol's resumable chunks and the hash computed while copying; the server checks that hash before it commits the
/// frame, and only then does the photo count as imported. Photos of one plan session share its session key, so the
/// server files them in one sequence — the same one when an interrupted import is started again. A typed session
/// title is set on that sequence once. A file the server refuses (a hash mismatch, a format it rejects) is listed in
/// <see cref="Report"/> and the import goes on (BRIEF §13: errors per file); a failed connection, sign-in or server
/// stops it. A file the server already held counts as a duplicate: the server answers so only for a copy that is not
/// flagged missing or damaged, and a server import never deletes anything from the card.
/// title is set on that sequence once; a whole folder's own name only on a sequence that has no title yet, so a rename
/// made on the server survives the next import of the folder. A file the server refuses (a hash mismatch, a format it
/// rejects) is listed in <see cref="Report"/> and the import goes on (BRIEF §13: errors per file); a failed connection,
/// sign-in or server stops it. A file the server already held counts as a duplicate: the server answers so only for a
/// copy that is not flagged missing or damaged, and a server import never deletes anything from the card.
/// </summary>
public sealed class ServerImportSink(ChronosClient client, string stagingDirectory) : IImportSink
{
@@ -85,16 +86,20 @@ public sealed class ServerImportSink(ChronosClient client, string stagingDirecto
Directory.Delete(folder);
}
if (committed is { Index: >= 0 } && session.Title is { Length: > 0 } title && _titled.Add(committed.SequenceId))
await SetTitleAsync(committed.SequenceId, title, cancellationToken).ConfigureAwait(false);
await SetTitleAsync(committed.SequenceId, title, keepExisting: title == session.DefaultTitle, cancellationToken).ConfigureAwait(false);
}
return results;
}
/// <summary>A refused title leaves the photos imported under the sequence's own name.</summary>
private async Task SetTitleAsync(Guid sequenceId, string title, CancellationToken cancellationToken)
/// <summary>
/// Names the sequence; with <paramref name="keepExisting"/> (the title the user did not type) only one without a
/// title. A refused title leaves the photos imported under the sequence's own name.
/// </summary>
private async Task SetTitleAsync(Guid sequenceId, string title, bool keepExisting, CancellationToken cancellationToken)
{
try
{
if (keepExisting && (await client.GetSequenceAsync(sequenceId, cancellationToken).ConfigureAwait(false)).Title is { Length: > 0 }) return;
await client.UpdateSequenceAsync(sequenceId, new UpdateSequenceRequest(title, null, null, null, null, null), cancellationToken).ConfigureAwait(false);
}
catch (ChronosApiException ex) when (IsRefusal(ex))
+2 -1
View File
@@ -102,13 +102,14 @@
</Style.Triggers>
</Style>
<!-- Up to four digits (gap ≤ 1440) in 56 px: half the usual side padding. -->
<!-- Up to four digits (gap ≤ 1440) in 56 px: half the usual side padding. A disabled box still says why in its tooltip. -->
<Style x:Key="TextBox.Small" TargetType="TextBox" BasedOn="{StaticResource TextBox.Number}">
<Setter Property="Width" Value="56" />
<Setter Property="Height" Value="30" />
<Setter Property="Padding" Value="4,0" />
<Setter Property="Margin" Value="6,0" />
<Setter Property="FlowDirection" Value="LeftToRight" />
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
</Style>
<!-- File paths and name templates stay left to right in every language (BRIEF §16). -->
+4 -1
View File
@@ -1134,7 +1134,10 @@ public sealed class ImportViewModel : SectionViewModel
else ApplyPlan();
}
/// <summary>Joins a session to the earlier one of the same camera and format (BRIEF §13: merge in the plan).</summary>
/// <summary>
/// Joins a session to the earlier one of the same camera and format, or for a whole folder of the same format
/// (BRIEF §13: merge in the plan).
/// </summary>
private void Merge(PlanSessionRow row)
{
_splits.Remove(row.FirstPath);
@@ -46,6 +46,9 @@ public sealed class ImportLanguageTests
var time = ImportPlans.Sessions(plan, ImportDestinationKind.Archive, new HashSet<string>())[0].TimeText;
Assert.Contains("←", time);
Assert.False(time.Contains('→'), "a right-to-left reader would see the arrow point back to the start");
var days = ImportPlans.Sessions(OverEightDays(), ImportDestinationKind.Archive, new HashSet<string>())[0].TimeText;
Assert.Contains("←", days);
Assert.False(days.Contains('→'), "also between two dates");
}
finally
{
@@ -1,5 +1,6 @@
using System.Globalization;
using Chronos.App.Import;
using Chronos.App.Infrastructure;
using Chronos.Core.Imaging;
using Chronos.Core.Import;
using Chronos.Core.Localization;
@@ -21,6 +22,10 @@ public sealed class ImportPlansTests
Session(3, "2026/2026-09-30 Canon EOS R5", Item(7, Start.AddDays(2), action: ImportAction.SkipImported)));
}
/// <summary>A whole folder shot over eight days, as one sequence.</summary>
internal static ImportPlan OverEightDays() =>
Plan(null, null, Session(1, "2026/Construction", Item(1, Start), Item(2, Start.AddDays(8).AddMinutes(3)))) with { Grouping = ImportGrouping.WholeFolder };
[Test]
public void TotalsCountWhatIsCopiedSkippedAndDuplicated()
{
@@ -105,6 +110,21 @@ public sealed class ImportPlansTests
Assert.Equal("Server", ImportPlans.Sessions(plan, ImportDestinationKind.Server, new HashSet<string>())[0].TargetText);
}
[Test]
public void ASessionThatEndsOnAnotherDayShowsBothDates()
{
var plan = OverEightDays();
var end = Start.AddDays(8).AddMinutes(3);
var time = ImportPlans.Sessions(plan, ImportDestinationKind.Archive, new HashSet<string>())[0].TimeText;
Assert.Equal($"{Formatting.Date(Start)} {Start.ToString("t", Loc.Culture)} → {Formatting.Date(end)} {end.ToString("t", Loc.Culture)}", time);
Assert.Equal(Loc.L("Import.Details.Session", 1, time), ImportPlans.Details(plan, ImportDestinationKind.Archive, verify: true).Rows[0].SourceText,
"the Show plan heading reads the same");
var sameDay = ImportPlans.Sessions(ThreeSessions(), ImportDestinationKind.Archive, new HashSet<string>())[0].TimeText;
Assert.Equal($"{Formatting.Date(Start)} · {Start.ToString("t", Loc.Culture)} → {Start.AddSeconds(8).ToString("t", Loc.Culture)}", sameDay,
"a session within one day shows its date once");
}
[Test]
public void ShowPlanListsEveryFileItsDestinationAndTheConflicts()
{
@@ -9,6 +9,7 @@ using Chronos.App.Infrastructure;
using Chronos.App.Sections;
using Chronos.App.Shell;
using Chronos.App.Tests.Windows;
using Chronos.Core.Import;
using Chronos.Core.Localization;
using Chronos.Testing;
using Chronos.Ui.Controls;
@@ -222,6 +223,75 @@ public sealed class ImportScreenSmokeTests
await import.WaitForPlanAsync();
});
/// <summary>
/// "Group" (BRIEF §12.4) is offered for a picked folder only, and a card is always planned by sessions. Switching the
/// grouping drops the splits made on the other grouping's sessions, and the session controls it turns off say why.
/// </summary>
[Test]
public Task AWholeFolderIsOfferedForAFolderOnlyAndDropsTheSplitsMadeBefore() => ScreenHost.RunAsync(async () =>
{
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
await app.Sample.FillAsync();
var import = app.Shell.Import;
var card = SampleCards.Card(app.Services.Environment.DataDirectory);
// A card: no Group choice, and asking for a whole folder changes nothing.
await ShowAsync(app, "plan");
Assert.False(import.CanGroupFolder);
import.GroupWholeFolder = true;
Assert.True(import.GroupBySessions);
Assert.Equal(ImportGrouping.Sessions, import.Choices.Grouping);
Assert.True(import.SessionsApply);
// The card's photos picked as a folder start by sessions: night, dawn and sunset.
await import.ImportFolderAsync(card.Root);
await import.WaitForPlanAsync();
Assert.True(import.CanGroupFolder);
Assert.True(import.GroupBySessions);
Assert.Equal((ImportGrouping.Sessions, 3), (import.Plan!.Grouping, import.Plan.Sessions.Count));
// The sunset split in two halves of twelve photos.
import.ShowPlanCommand.Execute(null);
import.SplitCommand.Execute(import.Details!.Rows.Where(r => r.Kind == PlanRowKind.File).ToList()[^12]);
await import.WaitForPlanAsync();
Assert.Equal(4, import.Plan!.Sessions.Count, "the split starts a session");
// The whole folder is one sequence for its one format, not cut where the sessions were split.
import.GroupWholeFolder = true;
await WaitUntilAsync(app, () => import.Plan is { Grouping: ImportGrouping.WholeFolder } && import.Phase == ImportPhase.Ready, "the whole folder is planned");
Assert.Equal(ImportGrouping.WholeFolder, import.Choices.Grouping);
Assert.Equal(1, import.Plan!.Sessions.Count);
Assert.False(import.SessionsApply);
Assert.False(import.GapApplies);
var why = Loc.L("Import.Blocked.WholeFolder");
Assert.Equal((why, why, why), (import.SessionsToolTip, import.GapMinutes.ToolTip, import.MinimumFrames.ToolTip));
var boxes = app.FindAll<TextBox>().Where(t => IsInImport(t) && EditBehavior.GetField(t) is { } f && (f == import.GapMinutes || f == import.MinimumFrames)).ToList();
Assert.Equal(2, boxes.Count);
foreach (var box in boxes)
{
Assert.False(box.IsEnabled);
Assert.True(ToolTipService.GetShowOnDisabled(box), "a disabled session box still shows why");
Assert.Equal(why, box.ToolTip as string);
}
// Back to sessions: the split made before stays gone.
import.GroupBySessions = true;
await WaitUntilAsync(app, () => import.Plan is { Grouping: ImportGrouping.Sessions } && import.Phase == ImportPhase.Ready, "the sessions are planned again");
Assert.Equal(3, import.Plan!.Sessions.Count);
Assert.True(import.SessionsApply);
Assert.Equal(Loc.L("Tooltips.Import.Gap"), import.GapMinutes.ToolTip);
// Choosing the card again leaves the folder's whole-folder choice behind.
import.GroupWholeFolder = true;
await WaitUntilAsync(app, () => import.Plan is { Grouping: ImportGrouping.WholeFolder } && import.Phase == ImportPhase.Ready, "the whole folder is planned");
import.SelectSource(card.Identity);
await import.WaitForPlanAsync();
Assert.False(import.CanGroupFolder);
Assert.True(import.GroupBySessions);
Assert.Equal(ImportGrouping.Sessions, import.Choices.Grouping);
Assert.Equal((ImportGrouping.Sessions, 3), (import.Plan!.Grouping, import.Plan.Sessions.Count));
});
/// <summary>As <c>--capture</c> does: toasts of the previous state go, those of an insertion state stay.</summary>
private static async Task ShowAsync(ScreenSmokeTests.SampleApp app, string state)
{
@@ -46,6 +46,39 @@ public sealed class ServerImportSinkTests(TestContext context)
Assert.Empty(Directory.EnumerateFileSystemEntries(staging));
}
[Test]
public async Task AWholeFolderImportedAgainKeepsTheNameItsSequenceWasGivenOnTheServer()
{
var folder = Card(Path.Combine(context.CreateTempDirectory("folder"), "Etna"), 4, Start);
var staging = context.CreateTempDirectory("staging");
var server = new FakeUploadServer(chunkSize: 4096);
using var client = new ChronosClient(new Uri("https://nas.local:8443/"), new CertificatePinning([]), "tests", server) { Token = "t" };
var destination = new UnindexedDestination(ImportDestinationKind.Server, staging);
var options = new ImportChoices { Grouping = ImportGrouping.WholeFolder }.ToOptions();
var first = await destination.PlanAsync(folder, options, null, null, context.Cancellation);
await LocalImport.RunAsync(first, new ServerImportSink(client, staging), "Etna", verify: true, null, context.Cancellation);
var (sequence, title) = server.Titles.Single();
Assert.Equal("Etna", title, "a new sequence takes the folder's name");
// Renamed on the server; a photo added to the folder joins the same sequence and leaves its name alone.
server.Titles[sequence] = "Etna 2026 eruption";
var photos = Path.Combine(folder, "DCIM", "100CANON");
File.WriteAllBytes(Path.Combine(photos, "IMG_0005.JPG"), Jpeg(Start.AddMinutes(10), 5));
var again = await destination.PlanAsync(folder, options, null, null, context.Cancellation);
var outcome = await LocalImport.RunAsync(again, new ServerImportSink(client, staging), "Etna", verify: true, null, context.Cancellation);
Assert.Equal((1, 4), (outcome.Copied, outcome.Duplicates));
Assert.Equal("Etna 2026 eruption", server.Titles[sequence]);
Assert.Equal(1, server.TitleUpdates, "only the new sequence was named");
// A title the user types still names it.
File.WriteAllBytes(Path.Combine(photos, "IMG_0006.JPG"), Jpeg(Start.AddMinutes(20), 6));
var typed = ImportPlans.WithTitles(await destination.PlanAsync(folder, options, null, null, context.Cancellation),
new Dictionary<string, string> { [again.Sessions[0].SessionKey] = "Etna at night" });
await LocalImport.RunAsync(typed, new ServerImportSink(client, staging), "Etna", verify: true, null, context.Cancellation);
Assert.Equal("Etna at night", server.Titles.Single().Value);
}
[Test]
public async Task PhotosTheServerAlreadyHoldsAreNotSentAgain()
{
@@ -233,7 +266,7 @@ public sealed class ServerImportSinkTests(TestContext context)
public void Advance(TimeSpan by) => Interlocked.Add(ref _ticks, by.Ticks);
}
/// <summary>Start, chunk and complete of BRIEF §14.4, plus the title update and card reports; the hash is checked at completion.</summary>
/// <summary>Start, chunk and complete of BRIEF §14.4, plus the sequence's title and card reports; the hash is checked at completion.</summary>
private sealed class FakeUploadServer(int chunkSize) : HttpMessageHandler
{
private readonly Dictionary<Guid, Upload> _open = [];
@@ -241,7 +274,11 @@ public sealed class ServerImportSinkTests(TestContext context)
private readonly Dictionary<string, Guid> _frames = new(StringComparer.Ordinal);
public List<Upload> Committed { get; } = [];
/// <summary>Each sequence's title on the server (a test may rename one, as a user would there).</summary>
public Dictionary<Guid, string> Titles { get; } = [];
public int TitleUpdates { get; private set; }
public int ChunkCount { get; private set; }
/// <summary>Flip a byte of every chunk of this file (a damaged transfer).</summary>
@@ -321,16 +358,21 @@ public sealed class ServerImportSinkTests(TestContext context)
return Json(new CompleteUploadResponse(frame, sequence, Committed.Count(u => u.SessionKey == upload.SessionKey) - 1),
ProtocolJson.Default.CompleteUploadResponse);
}
if (request.Method == HttpMethod.Get && path is ["api", "v1", "sequences", var read])
return Json(Sequence(Guid.Parse(read), Titles.GetValueOrDefault(Guid.Parse(read))), ProtocolJson.Default.SequenceDto);
if (request.Method == HttpMethod.Patch && path is ["api", "v1", "sequences", var sequenceId])
{
var update = (await request.Content!.ReadFromJsonAsync(ProtocolJson.Default.UpdateSequenceRequest, cancellationToken))!;
Titles[Guid.Parse(sequenceId)] = update.Title!;
return Json(new SequenceDto(Guid.Parse(sequenceId), update.Title, update.Title!, "f", null, null, null, null, null, 0, null, 0, 0, 0, null, [], 0, null,
1, 1, 0, null, DateTimeOffset.UtcNow), ProtocolJson.Default.SequenceDto);
TitleUpdates++;
return Json(Sequence(Guid.Parse(sequenceId), update.Title), ProtocolJson.Default.SequenceDto);
}
return new HttpResponseMessage(HttpStatusCode.NotFound);
}
private static SequenceDto Sequence(Guid id, string? title) =>
new(id, title, title ?? "f", "f", null, null, null, null, null, 0, null, 0, 0, 0, null, [], 0, null, 1, 1, 0, null, DateTimeOffset.UtcNow);
private static HttpResponseMessage Json<T>(T value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<T> type, HttpStatusCode status = HttpStatusCode.OK) =>
new(status) { Content = JsonContent.Create(value, type) };