feat(core): archive layout, sidecars, leases and thumbnail packs
archive.json and sequence.json with source-generated JSON, forward-compatible reading (unknown fields kept, unknown enum names tolerated) and atomic writes; lease files with expiry and stale takeover; thumbs.pack with index, crash-safe append and random access; folder scanning, in-place adoption, reconcile, verify, index snapshot, rename planning and thumbnail/proxy rendering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
24 files changed
+2556
No files matched your search
@@ -0,0 +1,46 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Titano.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(RenameJournal))]
|
||||
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 Titano 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());
|
||||
}
|
||||
Reference in new issue
Block a user