Files
Chronos/src/Chronos.App/Archive/ArchiveFailures.cs
T
Alby96andClaude Opus 5.5 a5facf0b5b 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>
2026-11-06 17:05:57 +01:00

30 lines
1.5 KiB
C#

using Chronos.App.Infrastructure;
using Chronos.Core.Archiving;
using Chronos.Core.Localization;
using Chronos.Data;
using Chronos.Data.Archiving;
namespace Chronos.App.Archiving;
/// <summary>
/// Why an Archive screen action stopped, as one localized sentence chosen by cause (BRIEF §0.2 rule 6). The
/// exception's own text, which may be technical or unlocalized, goes to the tooltip and the log only.
/// </summary>
public static class ArchiveFailures
{
public static string Cause(Exception ex) => ex switch
{
ArchiveOfflineException offline => Loc.L(offline.Availability == ArchiveAvailability.ReadOnly ? "Archive.Error.ReadOnly" : "Archive.Error.Offline",
Formatting.LeftToRight(offline.Root)),
// Already one localized sentence each; TrashMismatchException is a trash entry none of whose files matches its record
// any more (FrameTrash.RestoreAsync). Other IOExceptions and InvalidDataExceptions (a sidecar of another sequence)
// carry technical text.
LeaseUnavailableException or NewerFormatException or StaleRenamePlanException or NestedRenameException or StaleDeletePlanException
or SequenceInLibraryException or TrashMismatchException or Core.Project.ProjectTooLargeException or ArchiveStructureException => ex.Message,
UnauthorizedAccessException => Loc.L("Archive.Failed.Access"),
DatabaseException => Loc.L("Archive.Failed.Index"),
ArgumentException => Loc.L("Archive.Failed.Gone"),
_ => Loc.L("Archive.Failed.Files"),
};
}