feat: owner review 2 phase 4a: Reorganize sequences after import (#12)
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

- 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>
This commit was merged in pull request #12.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-27 21:58:39 +01:00
1 parent 9aa818ed47
commit 7e4a3b481d
416 files changed
+15304 -1572

No files matched your search

+11
View File
@@ -150,6 +150,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
session.Source.JobChanged += OnJobChanged;
session.Source.ReadOnlyChanged += OnReadOnlyChanged;
shell.Services.Sync.Changed += OnSyncChanged;
shell.Services.SequenceReorganized += OnSequenceReorganized;
UpdateMarkers();
RefreshSteps();
RequestCorrections();
@@ -708,6 +709,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
Session.Source.JobChanged -= OnJobChanged;
Session.Source.ReadOnlyChanged -= OnReadOnlyChanged;
Shell.Services.Sync.Changed -= OnSyncChanged;
Shell.Services.SequenceReorganized -= OnSequenceReorganized;
foreach (var tab in Tabs) tab.Dispose();
base.Dispose();
await Session.DisposeAsync();
@@ -1182,6 +1184,15 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
if (ServerJob is { } job) await Session.Source.CancelJobAsync(job.Id, CancellationToken.None);
}
/// <summary>
/// A Reorganize of this PC moved the folder of a sequence or renamed it or its files (any thread): the open sequence of
/// this PC is read again where it is now, so its frames decode and its project goes there.
/// </summary>
private void OnSequenceReorganized(Guid sequenceId) => _dispatcher.BeginInvoke(() =>
{
if (!_disposed && !IsRemote && sequenceId == Session.Content.Sequence.Id) _ = ReloadAsync(null);
});
/// <summary>The session, the sync links or the rights changed (any thread): whether the Export "Sync" option applies.</summary>
private void OnSyncChanged() => _dispatcher.BeginInvoke(() => _ = OnSyncChangedAsync());
+4 -3
View File
@@ -45,9 +45,10 @@ public interface ISequenceSource : IAsyncDisposable
Task<SequenceContent> LoadAsync(CancellationToken cancellationToken);
/// <summary>
/// Whether the frames <see cref="LoadAsync"/> read last are still the sequence's, in the same order: frames inserted
/// or removed since (a sync download, an import of earlier photos, a scan) moved the stored project's positions. A
/// server sequence whose frames changed becomes <see cref="IsOutdated"/>.
/// Whether the frames <see cref="LoadAsync"/> read last are still the sequence's, in the same order and folder: frames
/// inserted or removed since (a sync download, an import of earlier photos, a scan) moved the stored project's
/// positions, and a Reorganize may have moved the folder. A server sequence whose frames changed becomes
/// <see cref="IsOutdated"/>.
/// </summary>
/// <exception cref="EditorException">The sequence is gone.</exception>
Task<bool> FramesCurrentAsync(CancellationToken cancellationToken);
+26 -12
View File
@@ -51,6 +51,9 @@ public sealed class LocalSequenceSource : ISequenceSource
/// <summary>The frames version of the frames last read (<see cref="LoadAsync"/>), whose order the project's positions follow.</summary>
private int _framesVersion = -1;
/// <summary>The archive-relative folder the last read found the sequence in (<see cref="LoadAsync"/>); a Reorganize moves it.</summary>
private string? _relativeFolder;
private ArchivePaths? _paths;
private SequencePaths? _folder;
@@ -98,7 +101,8 @@ public sealed class LocalSequenceSource : ISequenceSource
if ((frames[i].Flags & FrameFlags.Missing) == 0) files[i] = paths.FromRelative(frames[i].RelativePath);
}
_companions = [.. frames.Select(f => companions.GetValueOrDefault(f.Id))];
(_paths, _folder, _files, _frameIds, _framesVersion) = (paths, folder, files, [.. frames.Select(f => f.Id)], sequence.FramesVersion);
(_paths, _folder, _relativeFolder, _files, _frameIds, _framesVersion) =
(paths, folder, sequence.Folder, files, [.. frames.Select(f => f.Id)], sequence.FramesVersion);
var context = SequenceContext.FromFrames(frames);
var (report, otherFrames) = ReadReport(folder, frames.Count);
return new SequenceContent(sequence, frames, ReadProject(sequence, folder), LightAnalyzer.Analyze(frames), report,
@@ -109,12 +113,15 @@ public sealed class LocalSequenceSource : ISequenceSource
}, cancellationToken);
}
/// <remarks>An insertion bumps the row's frames version in the transaction that renumbers the frames.</remarks>
/// <remarks>
/// An insertion bumps the row's frames version in the transaction that renumbers the frames; a Reorganize that moved
/// the folder leaves the version but not the files where they were read.
/// </remarks>
public async Task<bool> FramesCurrentAsync(CancellationToken cancellationToken)
{
var framesVersion = _framesVersion;
var (framesVersion, folder) = (_framesVersion, _relativeFolder);
var row = await _db.Sequences.GetAsync(_sequenceId, cancellationToken) ?? throw Missing();
return row.FramesVersion == framesVersion;
return row.FramesVersion == framesVersion && row.Folder == folder;
}
public async ValueTask<ImageBuffer?> DecodeAsync(int index, int maxLongEdge, DecodePurpose purpose, CancellationToken cancellationToken)
@@ -157,7 +164,7 @@ public sealed class LocalSequenceSource : ISequenceSource
{
ArgumentNullException.ThrowIfNull(project);
ArgumentNullException.ThrowIfNull(basis);
var (paths, folder, frameIds, framesVersion) = (_paths, _folder, _frameIds, _framesVersion);
var (paths, folder, relativeFolder, frameIds, framesVersion) = (_paths, _folder, _relativeFolder, _frameIds, _framesVersion);
if (paths is null || folder is null) throw new InvalidOperationException("LoadAsync first.");
return Task.Run(async () =>
{
@@ -168,8 +175,13 @@ public sealed class LocalSequenceSource : ISequenceSource
{
var row = await _db.Sequences.GetAsync(_sequenceId, cancellationToken) ?? throw Missing();
// Frames were inserted or removed since the editor read them, so its positions name the old order. Insertions
// hold this lease, so the frames do not change again before this save ends.
if (row.FramesVersion != framesVersion) throw new FramesChangedException(Loc.L("Editor.Error.FramesArriving"));
// hold this lease, so the frames do not change again before this save ends. A Reorganize moves the folder under
// it too: moved since the read, the project goes to the new folder once the editor read the sequence there,
// and the folder it left is never created again.
if (row.FramesVersion != framesVersion || row.Folder != relativeFolder) throw new FramesChangedException(Loc.L("Editor.Error.FramesArriving"));
// Moved by another index of the archive (a server's Reorganize), which this index finds at its next scan; the folder
// it left may hold another sequence that index moved into it since.
if (!SequenceFolders.Holds(folder, _sequenceId)) throw Missing();
var stored = ReadProject(row, folder);
var merged = ProjectMerge.SameValues(stored, basis) ? project : ProjectMerge.Merge(basis, project, stored);
var json = merged.ToJson();
@@ -218,9 +230,10 @@ public sealed class LocalSequenceSource : ISequenceSource
/// <summary>
/// The sequence row with its frames as one state: the frames are listed between two reads of the row that find the
/// same frames version (an insertion renumbers the frames and moves the row's positions in one transaction, and
/// bumps the version), so the project's positions name these frames.
/// bumps the version), so the project's positions name these frames, and the same folder (a Reorganize moves the
/// folder and rewrites the frames' paths in one transaction, the version kept), so the files are where they were read.
/// </summary>
/// <exception cref="EditorException">The sequence is gone, or an insertion landed during every attempt.</exception>
/// <exception cref="EditorException">The sequence is gone, or an insertion or a move landed during every attempt.</exception>
private async Task<(Sequence Row, List<Frame> Frames)> ReadFramesAsync(CancellationToken cancellationToken)
{
for (var attempt = 0; attempt < ReadAttempts; attempt++)
@@ -234,7 +247,7 @@ public sealed class LocalSequenceSource : ISequenceSource
if (page.Count < PageSize) break;
}
var after = await _db.Sequences.GetAsync(_sequenceId, cancellationToken) ?? throw Missing();
if (after.FramesVersion == before.FramesVersion) return (after, frames);
if (after.FramesVersion == before.FramesVersion && after.Folder == before.Folder) return (after, frames);
}
throw new EditorException(Loc.L("Editor.Error.FramesArriving"));
}
@@ -281,7 +294,8 @@ public sealed class LocalSequenceSource : ISequenceSource
}
/// <summary>
/// The frames of a sequence of this PC changed since the editor read them (frames inserted or removed): nothing was
/// saved. The editor reads them again, moves its positions as the index moved the stored ones, and saves again.
/// The frames of a sequence of this PC changed since the editor read them (frames inserted or removed, or their folder
/// moved by a Reorganize): nothing was saved. The editor reads them again, moves its positions as the index moved the
/// stored ones, and saves again.
/// </summary>
public sealed class FramesChangedException(string message) : EditorException(message);