Files
Chronos/src/Chronos.Core/Archiving/ArchiveJson.cs
T
Alby96andClaude Opus 5.5 7e4a3b481d
CI / Build and test (push) Successful in 9m15s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 15m35s
CI / PostgreSQL 16 integration (push) Successful in 7m26s
CI / PostgreSQL 17 integration (push) Successful in 6m47s
CI / Docker image (push) Successful in 59s
Release / Server image (push) Successful in 1m24s
feat: owner review 2 phase 4a: Reorganize sequences after import (#12)
- Reorganize… on the web panel and the desktop: folder, file and title templates applied to existing sequences, with a dry run and an explicit Apply that runs as a job.
- One naming rule (FrameNaming) for import, upload and Reorganize.
- Crash-safe plan and file journals, held plans, stale-plan refusal; exports move with their folder.
- Writers refuse a folder another program moved or gave to another sequence.
- Server: POST /api/v1/archive/reorganize with a bounded plan cache; template rules.
- Phase 3 docs and translations merged; strings in all 38 languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-10-27 21:58:39 +01:00

49 lines
2.2 KiB
C#

using System.Text.Json;
using System.Text.Json.Serialization;
namespace Chronos.Core.Archiving;
/// <summary>Source-generated metadata for every JSON file of the archive layout.</summary>
[JsonSourceGenerationOptions(
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
PropertyNameCaseInsensitive = true,
AllowTrailingCommas = true,
ReadCommentHandling = JsonCommentHandling.Skip)]
[JsonSerializable(typeof(ArchiveManifest))]
[JsonSerializable(typeof(SequenceManifest))]
[JsonSerializable(typeof(LeaseRecord))]
[JsonSerializable(typeof(IngestJournal))]
[JsonSerializable(typeof(FrameRemovalJournal))]
[JsonSerializable(typeof(RenameJournal))]
[JsonSerializable(typeof(FileRenameJournal))]
internal sealed partial class ArchiveJson : JsonSerializerContext;
/// <summary>Indented output for the small files people may open (<c>archive.json</c>, rename journals).</summary>
[JsonSourceGenerationOptions(
WriteIndented = true,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
[JsonSerializable(typeof(ArchiveManifest))]
[JsonSerializable(typeof(RenameJournal))]
internal sealed partial class ArchiveJsonIndented : JsonSerializerContext;
/// <summary>
/// Writes enum names and reads unknown names (written by a newer build) or numbers as the default value instead of
/// failing, so a sidecar from a newer Chronos is still readable.
/// </summary>
public sealed class TolerantEnumConverter<TEnum> : JsonConverter<TEnum>
where TEnum : struct, Enum
{
public override TEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.String && Enum.TryParse<TEnum>(reader.GetString(), ignoreCase: true, out var value)
&& Enum.IsDefined(value))
return value;
if (reader.TokenType is JsonTokenType.StartObject or JsonTokenType.StartArray) reader.Skip();
return default;
}
public override void Write(Utf8JsonWriter writer, TEnum value, JsonSerializerOptions options) => writer.WriteStringValue(value.ToString());
}