feat: owner review 2 phase 5b: the server as a project home (#17)
CI / Build and test (push) Successful in 9m58s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 14m8s
CI / PostgreSQL 16 integration (push) Successful in 8m55s
CI / PostgreSQL 17 integration (push) Successful in 8m50s
CI / Docker image (push) Successful in 57s
Release / Server image (push) Successful in 1m22s

A Chronos Server keeps its sequences' projects, as a PC's archive does: Main and named projects with versions under /api/v1/sequences/{id}/projects, the projects capability and the projectChanged event. The desktop opens a server's sequences in the workspace (proxies downloaded, hash-checked, resumable) with Save version, Sync, conflicts, History, Restore and the project actions against the server. Renders can be of a project version. The admin panel lists a sequence's projects and versions. 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>
This commit was merged in pull request #17.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-11-04 14:58:11 +01:00
1 parent 255e149087
commit 81c303f484
325 files changed
+11477 -516

No files matched your search

@@ -3,6 +3,7 @@ using Chronos.Core.Archiving;
using Chronos.Core.Conversion;
using Chronos.Core.Diagnostics;
using Chronos.Core.Import;
using Chronos.Core.IO;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Core.Naming;
@@ -348,6 +349,65 @@ public sealed class ArchiveService : IJobHandlerProvider
return await write(await _db.Sequences.GetAsync(sequence.Id, cancellationToken).ConfigureAwait(false)).ConfigureAwait(false);
}
/// <summary>
/// Settings a caller writes into the index (<paramref name="edit"/>: the server's <c>PATCH</c>, with its version checks)
/// written into the sequence's <c>project.json</c> too, under its lease, as every other writer of the settings does: so
/// the file never holds settings older than the index's, which the projects would take for the sequence's own when they
/// meet Main (<see cref="ProjectService"/>). <paramref name="settingsJson"/> goes to the file first; when the index then
/// does not take it (a conflict, the sequence gone) or the edit fails, the file is put back as it was. A sequence with no
/// folder yet is edited in the index alone: its first photo writes the file from the index.
/// </summary>
/// <param name="wait">How long the sequence's lease is waited for.</param>
/// <exception cref="ArgumentException">The sequence or its archive is not in the index.</exception>
/// <exception cref="ArchiveOfflineException">The archive is offline or read-only: nothing is written.</exception>
/// <exception cref="LeaseUnavailableException">Another writer held the sequence for longer than <paramref name="wait"/>: nothing is written.</exception>
/// <exception cref="SequenceFolderMovedException">The sequence's folder does not hold it now: nothing is written.</exception>
/// <exception cref="IOException">The file cannot be written: nothing is written.</exception>
public async Task<SequenceEditResult> EditSettingsAsync(Guid sequenceId, string settingsJson, Func<CancellationToken, Task<SequenceEditResult>> edit, TimeSpan wait,
CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(settingsJson);
ArgumentNullException.ThrowIfNull(edit);
var (archive, sequence) = await LoadSequenceAsync(sequenceId, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(sequence.Folder)) return await edit(cancellationToken).ConfigureAwait(false);
var paths = new ArchivePaths(archive.RootPath);
ArchiveVolume.EnsureWritable(paths);
await using (await _writer.LockAsync(paths, sequenceId, wait, cancellationToken).ConfigureAwait(false))
{
var row = await _db.Sequences.GetAsync(sequenceId, cancellationToken).ConfigureAwait(false) ?? throw Unknown(sequenceId);
var folder = paths.Sequence(row.Folder);
if (string.IsNullOrEmpty(row.Folder) || !SequenceFolders.Holds(folder, sequenceId)) throw new SequenceFolderMovedException();
var previous = File.Exists(folder.ProjectPath) ? AtomicFile.ReadAllText(folder.ProjectPath) : null;
Directory.CreateDirectory(folder.MetaDirectory);
AtomicFile.WriteAllText(folder.ProjectPath, settingsJson);
SequenceEditResult result;
try
{
result = await edit(cancellationToken).ConfigureAwait(false);
}
catch
{
PutBack(folder, previous);
throw;
}
if (result.Outcome != SequenceEditOutcome.Updated) PutBack(folder, previous);
return result;
}
static void PutBack(SequencePaths folder, string? previous)
{
try
{
if (previous is not null) AtomicFile.WriteAllText(folder.ProjectPath, previous);
else File.Delete(folder.ProjectPath);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
Log.Warning("archive", $"The project.json of {folder.RelativeFolder} could not be put back after an edit the index did not take", ex);
}
}
}
public Task<IReadOnlyList<DuplicateGroup>> FindDuplicatesAsync(Guid archiveId, CancellationToken cancellationToken = default) =>
Maintenance.FindDuplicatesAsync(archiveId, cancellationToken);