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>
336 lines
20 KiB
C#
336 lines
20 KiB
C#
using System.Security.Cryptography;
|
|
using Chronos.Core.Archiving;
|
|
using Chronos.Core.Localization;
|
|
using Chronos.Core.Model;
|
|
using Chronos.Core.Project;
|
|
using Chronos.Data.Archiving;
|
|
using Chronos.Data.Projects;
|
|
using Chronos.Data.Tests.Archiving;
|
|
using Chronos.Data.Tests.Infrastructure;
|
|
using Chronos.Data.Tests.Projects;
|
|
using Chronos.Data.Workspaces;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Data.Tests.Workspaces;
|
|
|
|
/// <summary>
|
|
/// The workspace survives a cut at every step (owner review 2, R8): a push, a replay and a save-both stopped between two
|
|
/// writes lose no version and make no false conflict, and the next sync finishes them; the files it writes are whole.
|
|
/// </summary>
|
|
[Category("workspace")]
|
|
public abstract class WorkspaceRecoveryTests(TestContext context) : DatabaseTest(context)
|
|
{
|
|
private async Task<WorkspaceFixture> FixtureAsync(int frames = 5, Func<ArchiveServiceOptions, ArchiveServiceOptions>? configure = null)
|
|
{
|
|
var archive = Own(await ArchiveFixture.CreateAsync(Context, database: await NewOptionsAsync(multiConnection: true), configure: configure));
|
|
return Own(await WorkspaceFixture.CreateAsync(Context, archive, frames));
|
|
}
|
|
|
|
private static async Task EditAsync(WorkspaceSync sync, Guid projectId, Func<ProjectSettings, ProjectSettings> edit, CancellationToken ct)
|
|
{
|
|
var session = await sync.OpenAsync(projectId, ct);
|
|
await sync.SaveAsync(projectId, edit(session.Working), ct);
|
|
}
|
|
|
|
private static ProjectSettings Offset(ProjectSettings s, double ev) => s with { Exposure = s.Exposure with { ExposureOffsetEv = ev } };
|
|
|
|
private static ProjectSettings Settings(ProjectVersion version) => ProjectSettings.FromJson(version.SettingsJson);
|
|
|
|
private static async Task<List<string?>> NotesAsync(WorkspaceFixture fx, Guid projectId) =>
|
|
[.. (await fx.Home.HistoryAsync(projectId, null, 50, fx.Ct)).OrderBy(v => v.Number).Select(v => v.Note)];
|
|
|
|
[Test]
|
|
public async Task APushCutAfterTheBaseMovedLosesNoVersionAndMakesNoFalseConflict()
|
|
{
|
|
var fx = await FixtureAsync();
|
|
var (store, sync) = fx.Workspace();
|
|
var project = await fx.CheckoutAsync(sync);
|
|
var id = project.ProjectId;
|
|
await EditAsync(sync, id, s => Offset(s, 0.5), fx.Ct);
|
|
var first = (await sync.CommitAsync(id, "first", cancellationToken: fx.Ct))!;
|
|
await EditAsync(sync, id, s => Offset(s, 0.8), fx.Ct);
|
|
var second = (await sync.CommitAsync(id, "second", cancellationToken: fx.Ct))!;
|
|
|
|
// Stored at the home, the base moved onto it, then the program died: 'second' still waits after it.
|
|
await Assert.ThrowsAsync<CutException>(() => WorkspaceFixture.Cutting(store, "push.base").PushAsync(id, fx.Home, fx.Ct));
|
|
var status = await sync.StatusAsync(id, fx.Home, fx.Ct);
|
|
Assert.Equal((WorkspaceState.Ahead, 1, 0, first.Id), (status.State, status.Ahead, status.Behind, status.Base!.VersionId));
|
|
Assert.Equal(second.Id, sync.Unpushed(id).Single().Id);
|
|
|
|
// The next sync, as the app runs it (pull, then push): no conflict, both versions at the home, the local file adopted.
|
|
Assert.Null((await sync.PullAsync(id, fx.Home, fx.Ct)).Status.Conflict);
|
|
Assert.Equal(WorkspaceState.InSync, (await sync.PushAsync(id, fx.Home, fx.Ct)).Status.State);
|
|
Assert.SequenceEqual(["first", "second"], (await NotesAsync(fx, id)).Skip(1));
|
|
Assert.Equal(0.8, Settings(await fx.Home.HeadAsync(id, fx.Ct)).Exposure.ExposureOffsetEv);
|
|
Assert.True(project.Versions().Where(v => v.Id == first.Id).All(v => v.StoredAt is not null), "the local file reads as sent");
|
|
Assert.Empty(project.Versions().Where(v => v.StoredAt is null));
|
|
}
|
|
|
|
[Test]
|
|
public async Task APushWhoseAnswerWasLostIsFinishedByTheNextSync()
|
|
{
|
|
var fx = await FixtureAsync();
|
|
var (_, sync) = fx.Workspace();
|
|
var project = await fx.CheckoutAsync(sync);
|
|
var id = project.ProjectId;
|
|
await EditAsync(sync, id, s => Offset(s, 0.5), fx.Ct);
|
|
await sync.CommitAsync(id, "first", cancellationToken: fx.Ct);
|
|
await EditAsync(sync, id, s => Offset(s, 0.8), fx.Ct);
|
|
await sync.CommitAsync(id, "second", cancellationToken: fx.Ct);
|
|
|
|
await Assert.ThrowsAsync<HomeUnavailableException>(() => sync.PushAsync(id, new CuttingHome(fx.Home) { LoseAnswer = 1 }, fx.Ct));
|
|
Assert.Equal(2, sync.Unpushed(id).Count);
|
|
Assert.Null((await sync.PullAsync(id, fx.Home, fx.Ct)).Status.Conflict);
|
|
Assert.Equal(WorkspaceState.InSync, (await sync.PushAsync(id, fx.Home, fx.Ct)).Status.State);
|
|
Assert.SequenceEqual(["first", "second"], (await NotesAsync(fx, id)).Skip(1));
|
|
Assert.Equal(0.8, Settings(await fx.Home.HeadAsync(id, fx.Ct)).Exposure.ExposureOffsetEv);
|
|
}
|
|
|
|
[Test]
|
|
public async Task AReplayCutAtAnyStepLosesNoVersionEvenWhenTheHomeMovesAgain()
|
|
{
|
|
var fx = await FixtureAsync();
|
|
var cuts = new[] { ("replay.journal", 1), ("replay.version", 1), ("replay.version", 2), ("replay.base", 1) };
|
|
foreach (var (step, occurrence) in cuts)
|
|
{
|
|
var label = $"{step} #{occurrence}";
|
|
var id = (await fx.Archive.Service.Projects.CreateAsync(fx.Sequence.Id, $"Cut {step} {occurrence}", cancellationToken: fx.Ct)).Id;
|
|
var (store, one) = fx.Workspace("one");
|
|
var (_, two) = fx.Workspace("two");
|
|
var project = await fx.CheckoutAsync(one, id);
|
|
await fx.CheckoutAsync(two, id);
|
|
await EditAsync(two, id, s => s with { Exposure = s.Exposure with { DeflickerStrength = new Auto<double>().WithManual(0.6) } }, fx.Ct);
|
|
await two.CommitAsync(id, cancellationToken: fx.Ct);
|
|
await two.PushAsync(id, fx.Home, fx.Ct);
|
|
await EditAsync(one, id, s => Offset(s, 0.3), fx.Ct);
|
|
await one.CommitAsync(id, "offset", cancellationToken: fx.Ct);
|
|
await EditAsync(one, id, s => s with { ExcludedFrames = [3], Stack = new StackSettings { Mode = StackSetting.Mean } }, fx.Ct);
|
|
await one.CommitAsync(id, "stack", cancellationToken: fx.Ct);
|
|
|
|
// The push meets the home moved: the replay is cut, then the home moves again before this PC syncs.
|
|
await Assert.ThrowsAsync<CutException>(() => WorkspaceFixture.Cutting(store, step, occurrence).PushAsync(id, fx.Home, fx.Ct));
|
|
Assert.Equal(2, one.Unpushed(id).Count, label);
|
|
await two.PullAsync(id, fx.Home, fx.Ct);
|
|
await EditAsync(two, id, s => s with { Exposure = s.Exposure with { DeflickerStrength = new Auto<double>().WithManual(0.7) } }, fx.Ct);
|
|
await two.CommitAsync(id, "again", cancellationToken: fx.Ct);
|
|
await two.PushAsync(id, fx.Home, fx.Ct);
|
|
|
|
Assert.Null((await one.PullAsync(id, fx.Home, fx.Ct)).Status.Conflict, label);
|
|
Assert.Equal(WorkspaceState.InSync, (await one.PushAsync(id, fx.Home, fx.Ct)).Status.State, label);
|
|
var notes = await NotesAsync(fx, id);
|
|
Assert.Equal((1, 1), (notes.Count(n => n == "offset"), notes.Count(n => n == "stack")), label);
|
|
var head = ProjectSettings.FromJson(ProjectContent.Place((await fx.Home.HeadAsync(id, fx.Ct)).SettingsJson, ProjectServiceTests.Photos(fx.Frames)));
|
|
Assert.Equal((0.7, 0.3, StackSetting.Mean), (head.Exposure.DeflickerStrength.Resolve(1), head.Exposure.ExposureOffsetEv, head.Stack.Mode), label);
|
|
Assert.SequenceEqual([3], head.ExcludedFrames, label);
|
|
Assert.Null(project.ReadSync().Replay, label);
|
|
Assert.Empty(project.Versions().Where(v => v.StoredAt is null));
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public async Task AConflictMetPastAVersionTheHomeHeldKeepsTheVersionsAfterIt()
|
|
{
|
|
var fx = await FixtureAsync();
|
|
var (_, one) = fx.Workspace("one");
|
|
var (_, two) = fx.Workspace("two");
|
|
var id = (await fx.CheckoutAsync(one)).ProjectId;
|
|
await fx.CheckoutAsync(two, id);
|
|
await EditAsync(one, id, s => Offset(s, 0.5), fx.Ct);
|
|
var first = (await one.CommitAsync(id, "first", cancellationToken: fx.Ct))!;
|
|
await EditAsync(one, id, s => s with { Stack = new StackSettings { Mode = StackSetting.Mean } }, fx.Ct);
|
|
var second = (await one.CommitAsync(id, "second", cancellationToken: fx.Ct))!;
|
|
// 'first' is stored, its answer lost; another PC builds on it.
|
|
await Assert.ThrowsAsync<HomeUnavailableException>(() => one.PushAsync(id, new CuttingHome(fx.Home) { LoseAnswer = 1 }, fx.Ct));
|
|
await two.PullAsync(id, fx.Home, fx.Ct);
|
|
await EditAsync(two, id, s => Offset(s, 1.0), fx.Ct);
|
|
await two.CommitAsync(id, "other", cancellationToken: fx.Ct);
|
|
await two.PushAsync(id, fx.Home, fx.Ct);
|
|
|
|
// This PC changed the offset too, without saving a version: a real conflict, met past 'first'.
|
|
await EditAsync(one, id, s => Offset(s, 2.0), fx.Ct);
|
|
var stopped = await one.PullAsync(id, fx.Home, fx.Ct);
|
|
Assert.Equal(WorkspaceState.Conflict, stopped.Status.State);
|
|
Assert.Equal((first.Id, 1), (stopped.Status.Base!.VersionId, stopped.Status.Ahead));
|
|
Assert.Equal(second.Id, one.Unpushed(id).Single().Id);
|
|
Assert.Equal("exposure.exposureOffsetEv", stopped.Status.Conflict!.Differences.Single().Path);
|
|
|
|
// The server's offset; 'second''s own change, which nobody else made, reaches the home.
|
|
await one.ResolveAsync(id, fx.Home, ConflictChoice.TakeServer, cancellationToken: fx.Ct);
|
|
Assert.Equal(WorkspaceState.InSync, (await one.PushAsync(id, fx.Home, fx.Ct)).Status.State);
|
|
var head = Settings(await fx.Home.HeadAsync(id, fx.Ct));
|
|
Assert.Equal((1.0, StackSetting.Mean), (head.Exposure.ExposureOffsetEv, head.Stack.Mode));
|
|
// The unsaved offset taken over is kept aside, never sent: the home holds exactly these versions, in order.
|
|
Assert.SequenceEqual(["first", "other", "second"], (await NotesAsync(fx, id)).Skip(1));
|
|
}
|
|
|
|
[Test]
|
|
public async Task ASaveBothCutShortIsFinishedIntoTheSameCopy()
|
|
{
|
|
var fx = await FixtureAsync();
|
|
var (_, one) = fx.Workspace("one");
|
|
var (store, three) = fx.Workspace("three");
|
|
var id = (await fx.CheckoutAsync(one)).ProjectId;
|
|
var project = await fx.CheckoutAsync(three, id);
|
|
await EditAsync(one, id, s => Offset(s, 0.5), fx.Ct);
|
|
await one.CommitAsync(id, cancellationToken: fx.Ct);
|
|
await one.PushAsync(id, fx.Home, fx.Ct);
|
|
await EditAsync(three, id, s => Offset(s, 2), fx.Ct);
|
|
await three.CommitAsync(id, "bright", cancellationToken: fx.Ct);
|
|
await EditAsync(three, id, s => s with { Stack = new StackSettings { Mode = StackSetting.StarTrails } }, fx.Ct);
|
|
Assert.Equal(WorkspaceState.Conflict, (await three.PushAsync(id, fx.Home, fx.Ct)).Status.State);
|
|
|
|
// The copy is made and the first version sent, then the home goes out of reach.
|
|
var cut = new CuttingHome(fx.Home) { Refuse = 2 };
|
|
await Assert.ThrowsAsync<HomeUnavailableException>(() => three.ResolveAsync(id, cut, ConflictChoice.SaveBoth, saveBothName: "Main (PC)", cancellationToken: fx.Ct));
|
|
var partial = (await fx.Home.ListAsync(fx.Ct)).Single(p => p.Name == "Main (PC)");
|
|
Assert.Equal(WorkspaceState.Conflict, (await three.StatusAsync(id, fx.Home, fx.Ct)).State);
|
|
|
|
// The retry, asked another name as the app asks once the first is taken, sends the rest to the same copy.
|
|
var both = await three.ResolveAsync(id, fx.Home, ConflictChoice.SaveBoth, saveBothName: "Main (other)", cancellationToken: fx.Ct);
|
|
Assert.Equal(partial.Id, both.SavedAs!.Id);
|
|
Assert.Equal(2, (await fx.Home.ListAsync(fx.Ct)).Count);
|
|
var kept = Settings(await fx.Home.HeadAsync(partial.Id, fx.Ct));
|
|
Assert.Equal((2, StackSetting.StarTrails), (kept.Exposure.ExposureOffsetEv, kept.Stack.Mode));
|
|
Assert.Equal(3, (await fx.Home.HistoryAsync(partial.Id, null, 10, fx.Ct)).Count);
|
|
Assert.Equal(WorkspaceState.InSync, both.Status.State);
|
|
Assert.Equal(WorkspaceSyncState.None, project.ReadSync());
|
|
|
|
// Cut once this project moved onto the home's head: the next sync finishes it, the conflict settled.
|
|
await EditAsync(one, id, s => Offset(s, 0.7), fx.Ct);
|
|
await one.CommitAsync(id, cancellationToken: fx.Ct);
|
|
await one.PushAsync(id, fx.Home, fx.Ct);
|
|
await EditAsync(three, id, s => Offset(s, 3), fx.Ct);
|
|
await three.CommitAsync(id, "brighter", cancellationToken: fx.Ct);
|
|
Assert.Equal(WorkspaceState.Conflict, (await three.PushAsync(id, fx.Home, fx.Ct)).Status.State);
|
|
await Assert.ThrowsAsync<CutException>(() => WorkspaceFixture.Cutting(store, "saveboth.base").ResolveAsync(id, fx.Home, ConflictChoice.SaveBoth, cancellationToken: fx.Ct));
|
|
var settled = await three.PushAsync(id, fx.Home, fx.Ct);
|
|
Assert.Equal((WorkspaceState.InSync, 0), (settled.Status.State, settled.Status.Ahead));
|
|
Assert.Equal(0.7, (await three.OpenAsync(id, fx.Ct)).Working.Exposure.ExposureOffsetEv);
|
|
var second = (await fx.Home.ListAsync(fx.Ct)).Single(p => p.Name == "Main (2)");
|
|
Assert.Equal(3, Settings(await fx.Home.HeadAsync(second.Id, fx.Ct)).Exposure.ExposureOffsetEv);
|
|
Assert.Equal(WorkspaceSyncState.None, project.ReadSync());
|
|
Assert.Empty(project.Versions().Where(v => v.StoredAt is null));
|
|
}
|
|
|
|
[Test]
|
|
public async Task AProjectWithTwentyThousandParkedExclusionsIsCheckedOutEditedAndSent()
|
|
{
|
|
var fx = await FixtureAsync(3);
|
|
var projects = fx.Archive.Service.Projects;
|
|
var large = await projects.CreateAsync(fx.Sequence.Id, "Large", cancellationToken: fx.Ct);
|
|
var head = await projects.HeadAsync(large.Id, fx.Ct);
|
|
// Exclusions of photos this sequence does not hold (taken from another copy): they wait, parked by photo.
|
|
var pending = Enumerable.Range(0, 20_000).Select(i => new PendingFrame
|
|
{
|
|
Sha256 = Convert.ToHexStringLower(SHA256.HashData(BitConverter.GetBytes(i))),
|
|
Size = 1_000_000 + i,
|
|
CapturedAt = new DateTime(2024, 1, 1).AddMinutes(i),
|
|
Excluded = true,
|
|
}).ToList();
|
|
var portable = ProjectContent.Canonical((Settings(head) with { PendingFrames = pending }).ToJson());
|
|
var draft = head with
|
|
{
|
|
Id = Guid.CreateVersion7(),
|
|
ParentId = head.Id,
|
|
Number = head.Number + 1,
|
|
Kind = ProjectVersionKind.Commit,
|
|
SettingsJson = portable,
|
|
ContentHash = ProjectContent.Hash(portable),
|
|
StoredAt = null,
|
|
};
|
|
Assert.Equal(PushOutcome.Stored, (await projects.PushAsync(large.Id, draft, fx.Ct)).Outcome);
|
|
|
|
var (_, sync) = fx.Workspace();
|
|
var project = await fx.CheckoutAsync(sync, large.Id);
|
|
Assert.True(new FileInfo(project.BundlePath).Length > 4 << 20, "larger than a project file could be before");
|
|
var session = await sync.OpenAsync(large.Id, fx.Ct);
|
|
Assert.Equal(20_000, session.Working.PendingFrames!.Count);
|
|
await sync.SaveAsync(large.Id, Offset(session.Working, 0.2), fx.Ct);
|
|
Assert.NotNull(await sync.CommitAsync(large.Id, cancellationToken: fx.Ct));
|
|
Assert.Equal(WorkspaceState.InSync, (await sync.PushAsync(large.Id, fx.Home, fx.Ct)).Status.State);
|
|
Assert.Equal(20_000, Settings(await fx.Home.HeadAsync(large.Id, fx.Ct)).PendingFrames!.Count);
|
|
}
|
|
|
|
[Test]
|
|
public async Task TheCopyStopsBeforeItFillsTheWorkspaceDrive()
|
|
{
|
|
var fx = await FixtureAsync(3, options => options with { FreeSpace = _ => 1 << 20 });
|
|
var (store, sync) = fx.Workspace();
|
|
var main = await fx.Archive.Service.Projects.MainAsync(fx.Sequence.Id, fx.Ct);
|
|
var project = await sync.CheckoutAsync(fx.Home, main.Id, cancellationToken: fx.Ct);
|
|
var job = await fx.CopyAsync(store, main.Id, JobState.Failed);
|
|
var parts = Loc.L("Errors.Workspace.DiskFull", "\u0001").Split('\u0001');
|
|
Assert.True(job.Error!.StartsWith(parts[0], StringComparison.Ordinal) && job.Error.EndsWith(parts[1], StringComparison.Ordinal), job.Error);
|
|
Assert.Null(project.ReadMedia());
|
|
Assert.Empty(Directory.GetFiles(project.ProxiesDirectory));
|
|
}
|
|
|
|
[Test]
|
|
public async Task ACopyResumedAfterTheSequenceMovedChecksEveryFileAgain()
|
|
{
|
|
var fx = await FixtureAsync();
|
|
var (store, sync) = fx.Workspace();
|
|
var main = await fx.Archive.Service.Projects.MainAsync(fx.Sequence.Id, fx.Ct);
|
|
var project = await sync.CheckoutAsync(fx.Home, main.Id, cancellationToken: fx.Ct);
|
|
await fx.Archive.Service.Images.BuildProxiesAsync(fx.Archive.Archive, fx.Sequence, force: false, 0, (_, _) => ValueTask.CompletedTask, fx.Ct);
|
|
await fx.CopyAsync(store, main.Id);
|
|
var copied = project.ReadMedia()!;
|
|
var damaged = project.MediaFile(copied.Frames[0].File!);
|
|
|
|
// A run of the same frames in the same folder keeps what it had copied.
|
|
File.WriteAllText(damaged, "not a photo");
|
|
var job = await fx.CopyAsync(store, main.Id, checkpoint: $"copy:{copied.Frames.Count}:{fx.Sequence.FramesVersion}:{fx.Sequence.Folder}");
|
|
Assert.Contains(Loc.L("Archive.Log.WorkspaceCopied", fx.Sequence.DisplayTitle, 0, 0, 5, 0), job.LogTail!);
|
|
// One read in another folder (the sequence moved since, another may hold its old one) checks every file again.
|
|
job = await fx.CopyAsync(store, main.Id, checkpoint: $"copy:{copied.Frames.Count}:{fx.Sequence.FramesVersion}:elsewhere/folder");
|
|
Assert.Contains(Loc.L("Archive.Log.WorkspaceCopied", fx.Sequence.DisplayTitle, 1, 0, 4, 0), job.LogTail!);
|
|
Assert.Equal(copied.Frames[0].FileSha256, Convert.ToHexStringLower(SHA256.HashData(File.ReadAllBytes(damaged))));
|
|
}
|
|
|
|
[Test]
|
|
public async Task TheEditorReadsTheWorkingStateAndTheMediaUnderTheLease()
|
|
{
|
|
var fx = await FixtureAsync(2);
|
|
var (store, sync) = fx.Workspace();
|
|
var project = await fx.CheckoutAsync(sync);
|
|
var impatient = new WorkspaceSync(store, "Chronos test") { LockWait = TimeSpan.FromMilliseconds(200) };
|
|
using (await project.LockAsync(TimeSpan.FromSeconds(TestTiming.Budget(5)), fx.Ct))
|
|
await Assert.ThrowsAsync<LeaseUnavailableException>(() => impatient.OpenAsync(project.ProjectId, fx.Ct));
|
|
Assert.NotNull((await impatient.OpenAsync(project.ProjectId, fx.Ct)).Sequence);
|
|
}
|
|
|
|
[Test]
|
|
public void AManifestLeftUnfinishedIsMadeAgainOnlyWhileTheFolderHoldsNoProject()
|
|
{
|
|
var root = Path.Combine(Context.CreateTempDirectory("ws"), "workspace");
|
|
Directory.CreateDirectory(root);
|
|
var manifest = Path.Combine(root, WorkspaceStore.ManifestFile);
|
|
File.WriteAllBytes(manifest, []);
|
|
var store = new WorkspaceStore(root);
|
|
Assert.Equal(WorkspaceStore.FormatName, store.Manifest.Format);
|
|
Assert.Empty(Directory.GetFiles(root, "*.tmp"));
|
|
Assert.Equal(store.Id, new WorkspaceStore(root).Id);
|
|
|
|
File.WriteAllText(manifest, """{ "format": "chronos-wor""");
|
|
Assert.NotEqual(store.Id, new WorkspaceStore(root).Id);
|
|
|
|
// With a project in the folder, a damaged manifest is never written over: it is reported.
|
|
var project = Path.Combine(root, Guid.CreateVersion7().ToString("N"));
|
|
Directory.CreateDirectory(project);
|
|
File.WriteAllText(Path.Combine(project, WorkspaceProject.BundleFile), "{}");
|
|
File.WriteAllText(manifest, """{ "format": "chronos-wor""");
|
|
Assert.Throws<InvalidDataException>(() => new WorkspaceStore(root));
|
|
}
|
|
}
|
|
|
|
public sealed class SqliteWorkspaceRecoveryTests(TestContext context) : WorkspaceRecoveryTests(context)
|
|
{
|
|
protected override Backend Backend => Backend.SqliteFile;
|
|
}
|
|
|
|
[RequiresEnvironment(PgTestServer.Variable)]
|
|
public sealed class PostgresWorkspaceRecoveryTests(TestContext context) : WorkspaceRecoveryTests(context)
|
|
{
|
|
protected override Backend Backend => Backend.Postgres;
|
|
}
|