fix: keep pre-rule templates through web settings saves; retry render filing after another index moved the folder

The web panel's archive settings save checked both request templates against
every template rule before the engine ran, so an archive.json saved before the
rules made every save fail, even of the name or proxy size. Only a template that
differs from the stored one is now held to the rules, as ArchiveService already
does, and a TemplateRuleException from the engine (archive.json changed since the
form was read) answers invalid_template with its rule instead of archive_policy.

Exports follow a moved folder correctly in two more cases. Image-sequence exports
are folders, so the rebase now tests Path.Exists instead of File.Exists. An
export left at the old path no longer pins a sequence's row when that path now
belongs to another sequence (its sidecar holds the old folder, or its render row
names the path); the row follows to the new path, so it never names another
sequence's file.

RenderStore throws FolderMovedException when the sequence is not in the folder
the index has. That is transient until this index's next scan, so client render
uploads and render-node results now answer 503 folder_moved, keep the part file
and the node's job, instead of failing them for good with a wrong reason.

Save both and Take server refused because the folder moved now say
Errors.Archive.FolderMoved (try again after the next scan) instead of the
"changed again, choose again" sentence, which repeated until a scan.

Doc wording: the ReorganizeDialogViewModel summary covers a sequence kept whole,
and RenamePlanner.Plan's existsExactly says the own folder is found under at most
one of the two names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit d898798657197d48f4e19b7f776003eb2fc441b5)
This commit is contained in:
Alby96 committed 2026-10-27 19:46:16 +01:00
1 parent d0da224de5
commit 964b996af2
21 files changed
+239 -46

No files matched your search

+24 -5
View File
@@ -177,14 +177,16 @@ public sealed class SyncService
/// <summary>
/// Settles a conflict as the user chose (BRIEF §12.7), against the versions the user was shown: when either side
/// changed again since, nothing is written, the sequence is compared again and <see cref="SyncConflictChangedException"/>
/// is thrown, as it is when <see cref="SyncResolution.SaveBoth"/> cannot keep this PC's version first (the folder is not
/// where the index has it). Returns the file this PC's settings were saved to for <see cref="SyncResolution.SaveBoth"/>,
/// else null.
/// is thrown, as it is when <see cref="SyncResolution.SaveBoth"/> cannot keep this PC's version first or the server's
/// version cannot be written because the folder is not where the index has it (another index moved it; its message then
/// says to try again after the next scan). Returns the file this PC's settings were saved to for
/// <see cref="SyncResolution.SaveBoth"/>, else null.
/// </summary>
public async Task<string?> ResolveAsync(ISyncRemote remote, Guid remoteId, SyncResolution resolution, CancellationToken cancellationToken)
{
string? saved = null;
var changed = false;
var moved = false;
await _gate.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
@@ -229,6 +231,7 @@ public sealed class SyncService
// This PC's version could not be kept (another index moved the folder): the server's does not replace it,
// even where this index's scan finds the folder before the server's version would be written.
changed = true;
moved = true;
}
else
{
@@ -239,8 +242,10 @@ public sealed class SyncService
}
else
{
// Edited on this PC since it was read: the copy of a version the user did not choose to keep goes.
// Edited on this PC since it was read, or the folder moved by another index: the copy of a version the
// user did not choose to keep goes.
changed = true;
moved = await FolderMovedAsync(local, cancellationToken).ConfigureAwait(false);
if (saved is not null) await DeleteCopyAsync(local, saved, cancellationToken).ConfigureAwait(false);
saved = null;
}
@@ -259,7 +264,8 @@ public sealed class SyncService
if (changed)
{
await RefreshSequencesAsync(remote, [remoteId], CompareOnly, cancellationToken).ConfigureAwait(false);
throw new SyncConflictChangedException(Loc.L("Errors.Sync.ChangedAgain"));
// Choosing again changes nothing while the folder is not where the index has it: the next scan finds it.
throw new SyncConflictChangedException(Loc.L(moved ? "Errors.Archive.FolderMoved" : "Errors.Sync.ChangedAgain"));
}
await StoreStatesAsync(remote.Server, null, cancellationToken).ConfigureAwait(false);
Changed?.Invoke(remote.Server);
@@ -823,6 +829,19 @@ public sealed class SyncService
return path;
}
/// <summary>
/// Whether the sequence is not in the folder the index has for it now, on an archive that is there: another index moved
/// it, and this index's next scan finds it. Read without the lease, to tell why a resolution wrote nothing.
/// </summary>
private async Task<bool> FolderMovedAsync(Sequence local, CancellationToken cancellationToken)
{
if (await _db.Sequences.GetAsync(local.Id, cancellationToken).ConfigureAwait(false) is not { } row
|| await _db.Archives.GetAsync(row.ArchiveId, cancellationToken).ConfigureAwait(false) is not { } archive)
return false;
var paths = new ArchivePaths(archive.RootPath);
return Directory.Exists(paths.Root) && !Directory.Exists(paths.Sequence(row.Folder).Folder);
}
/// <summary>
/// Deletes a "Save both" copy of a version the user did not keep from the sequence's folder as the index has it now: a
/// Reorganize may have moved the folder, the copy with it, since the copy was written. Best effort: a copy that cannot