feat(archive): lay out the archive's whole folder tree wherever its root is
The owner asked (2026-11-06) that whatever path is given as the archive root, on the server in Docker or on Windows, Chronos creates inside it every folder the archive keeps. Until now only .chronos was made up front; locks, journal, staging, trash and its photos and videos areas appeared on first use, and an archive copied or made by an older build could lack them. ArchiveStructure.Ensure (Core) creates the missing folders of BRIEF §7 idempotently, never touching existing folders or files, and reports why it could not (drive or share unavailable, permission denied, read-only, a file in the way) as one localized sentence. ArchiveService runs it when it creates an archive (refused with the reason when the tree cannot be made) and at every open. The server checks it at start-up and on each dashboard read: it logs a warning, the dashboard shows an "Archive incomplete" chip with the reason, and /health reports archive "incomplete". The desktop runs it when an archive is created, adopted or opened at start, and a folder typed in Settings that is not an archive yet becomes one in place, as Welcome's Create does; a writable archive whose tree cannot be completed is refused with the reason. Refs #31 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fe50b87726
commit
a5facf0b5b
24 files changed
+605
-21
No files matched your search
@@ -26,6 +26,11 @@ public abstract class SequenceTrashTests(TestContext context) : DatabaseTest(con
|
||||
return sequences;
|
||||
}
|
||||
|
||||
/// <summary>What the trash holds besides its photos and videos areas, which every archive has (empty here).</summary>
|
||||
private static IEnumerable<string> TrashContents(ArchivePaths paths) =>
|
||||
Directory.EnumerateFileSystemEntries(paths.TrashDirectory, "*", SearchOption.AllDirectories)
|
||||
.Where(e => e != paths.TrashPhotosDirectory && e != paths.TrashVideosDirectory);
|
||||
|
||||
private static (int Files, long Bytes) OnDisk(string folder)
|
||||
{
|
||||
var files = new DirectoryInfo(folder).EnumerateFiles("*", SearchOption.AllDirectories).ToList();
|
||||
@@ -109,7 +114,7 @@ public abstract class SequenceTrashTests(TestContext context) : DatabaseTest(con
|
||||
Assert.Equal(6, plan.Frames);
|
||||
Assert.Equal(before, await Photos.DumpIndexAsync(fx.Db, fx.Archive.Id));
|
||||
Assert.True(Directory.Exists(folder), "a dry run moves nothing");
|
||||
Assert.False(Directory.Exists(SequenceTrash.TrashDirectory(fx.Paths)));
|
||||
Assert.Empty(TrashContents(fx.Paths));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -166,7 +171,7 @@ public abstract class SequenceTrashTests(TestContext context) : DatabaseTest(con
|
||||
Assert.Equal(before, await Photos.DumpIndexAsync(fx.Db, fx.Archive.Id));
|
||||
Assert.Equal(render.OutputPath, (await fx.Db.Renders.ListBySequenceAsync(victim.Id)).Single().OutputPath);
|
||||
Assert.Empty(await fx.Service.ListTrashAsync(fx.Archive.Id, fx.Ct));
|
||||
Assert.Empty(Directory.EnumerateFileSystemEntries(SequenceTrash.TrashDirectory(fx.Paths)));
|
||||
Assert.Empty(TrashContents(fx.Paths));
|
||||
Assert.Equal(0, (await fx.ScanAsync()).Indexed);
|
||||
|
||||
// Deleted again: the trash takes it again under the same name.
|
||||
@@ -360,7 +365,7 @@ public abstract class SequenceTrashTests(TestContext context) : DatabaseTest(con
|
||||
|
||||
Assert.True(Directory.Exists(folder), "the folder is back where it was");
|
||||
Assert.Equal(before, await Photos.DumpIndexAsync(fx.Db, fx.Archive.Id));
|
||||
Assert.Empty(Directory.EnumerateFileSystemEntries(SequenceTrash.TrashDirectory(fx.Paths)));
|
||||
Assert.Empty(TrashContents(fx.Paths));
|
||||
await HealSequencesAsync(fx, "DELETE");
|
||||
Assert.Count(1, await fx.Service.DeleteAsync(await fx.Service.PlanDeleteAsync([victim.Id], null, fx.Ct), null, null, fx.Ct));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user