fix(archive): exports follow a Reorganize folder move; writers resolve the folder under the lease
A Reorganize step that moves a sequence folder carries its exports/ with it, but only the sequences and frames rows followed: renders.output_path kept naming the old folder, so the server answered 404 for the export, Get/Send exports and Reveal lost it, and no scan or trash restore could repair it. RenderRepository.RebaseFolderAsync now rewrites the archive-relative output paths of the step's sequence in the same transaction as the frames (idempotent on resume; absolute outputs and the archive root are untouched). Writers that read a sequence row before taking its lease wrote into the folder a Reorganize had moved meanwhile, creating it again (project.json from the editor or a sync, a thumbnail pack) or failing on its missing sidecar. They now take the folder from the index row read under the lease (SequenceWriter.FolderAsync): the editor's save refuses with FramesChangedException and reloads at the new folder, FramesCurrentAsync reports a moved folder, and the sync apply, project store, thumbnail pass and its status, decode tiers, analyses, verify, info edits, ingest, duplicate flags, pack compaction and photo restores write where the sequence is now; a photo deletion planned before the move is refused as stale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit be28d8acf0d96012c94a266f8af61e9bbafaa28d)
This commit is contained in:
1 parent
b253cac8d4
commit
9ce201cd70
22 files changed
+343
-35
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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,10 @@ 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"));
|
||||
var stored = ReadProject(row, folder);
|
||||
var merged = ProjectMerge.SameValues(stored, basis) ? project : ProjectMerge.Merge(basis, project, stored);
|
||||
var json = merged.ToJson();
|
||||
@@ -281,7 +290,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);
|
||||
Reference in new issue
Block a user