fix(server): keep convert dry runs like Reorganize's, say what a new sequence lacks
The convert endpoint planned the whole selection inside the HTTP request, again for every mode, quality keystroke and confirmation, with no limit: behind a proxy an all-sequence conversion could never get past its dry run or its apply. - ReorganizePlanCache becomes PlanCache, shared by Reorganize and Convert: one plan per key made apart from the request, two at once across both kinds, eight kept, 15-minute timeout, 5-minute lifetime, 503 plan_dropped. Keys are typed records (ReorganizePlanKey, ConvertPlanKey) that also say which exceptions are refusals. - A conversion plan is keyed by archive, a convert stamp of the index (SequenceRepository.GetConvertStampAsync: the Reorganize stamp plus, per planned sequence, the photos' count, sizes, formats, pixel sizes and missing, corrupt, preview-only and undecodable flags), the sequences and the target with the quality that counts. Not the mode: the request's mode and options are set on the kept plan, and the free space is measured again at every request through the engine. A plan made while the volume was away is not kept (503 archive_offline). - New sequence holds the converted copies alone: the dry run says the skipped photos are not copied into it (Archive.Convert.NotCopied.*, Server.Convert.OnPcNew), the panel's totals, column and confirmation give the count, and so does the desktop's summary. - Panel: the preview is asked in Replace's neutral words; a dry run cut off by a proxy is asked again while the totals show how long it takes, plan_dropped is retried once; an apply the server let go plans again, a changed one shows Admin.Convert.PlanChanged, and one with no answer is not resent (its job may be queued). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit f0b1e379ce7c08b6d3459ab25ca6214c8f366f6c)
This commit is contained in:
1 parent
d0bbd77c92
commit
8174852a2c
22 files changed
+927
-342
No files matched your search
@@ -42,14 +42,22 @@ public static class ConvertPlans
|
||||
/// <summary>A valid quality as typed (see <see cref="ValidateQuality"/>).</summary>
|
||||
public static int ParseQuality(string text) => int.Parse(text.Trim(), NumberStyles.Integer, Loc.Culture);
|
||||
|
||||
/// <summary>The rows of a plan in its order: every sequence that converts, or whose photos stay as they are, with why.</summary>
|
||||
/// <summary>
|
||||
/// The rows of a plan in its order: every sequence that converts, or whose photos stay as they are, with why in the
|
||||
/// words of the plan's mode (<see cref="Row"/>).
|
||||
/// </summary>
|
||||
public static IReadOnlyList<ConvertRow> Rows(ConvertPlan plan)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(plan);
|
||||
return [.. plan.Sequences.Where(s => s.Frames.Count > 0 || s.Skipped.Count > 0 || s.Blocked.Count > 0).Select(Row)];
|
||||
return [.. plan.Sequences.Where(s => s.Frames.Count > 0 || s.Skipped.Count > 0 || s.Blocked.Count > 0).Select(s => Row(s, plan.Mode))];
|
||||
}
|
||||
|
||||
public static ConvertRow Row(ConvertSequencePlan step)
|
||||
/// <summary>
|
||||
/// One sequence of a plan: what converts, then what blocks it, then the photos skipped with why. With
|
||||
/// <see cref="ConvertMode.NewSequence"/> those are not copied into the new sequence, which holds the converted copies
|
||||
/// alone; with <see cref="ConvertMode.Replace"/> they stay as they are.
|
||||
/// </summary>
|
||||
public static ConvertRow Row(ConvertSequencePlan step, ConvertMode mode = ConvertMode.Replace)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(step);
|
||||
var named = !string.IsNullOrWhiteSpace(step.Title);
|
||||
@@ -59,7 +67,8 @@ public static class ConvertPlans
|
||||
: string.Empty;
|
||||
// What blocks the whole sequence comes first: the photos it would skip anyway do not matter until it can convert.
|
||||
List<string> kept = [.. step.Blocked.Distinct().Select(b => Loc.L("Archive.Convert.Blocked." + b))];
|
||||
kept.AddRange(step.Skipped.Select(s => Loc.L("Archive.Convert.Skipped." + s.Reason) + Loc.Separator + Loc.Plural("Shell.Status.Photos", s.Frames)));
|
||||
var why = mode == ConvertMode.NewSequence ? "Archive.Convert.NotCopied." : "Archive.Convert.Skipped.";
|
||||
kept.AddRange(step.Skipped.Select(s => Loc.L(why + s.Reason) + Loc.Separator + Loc.Plural("Shell.Status.Photos", s.Frames)));
|
||||
return new ConvertRow(step.SequenceId, name, !named, note, kept, step.Blocked.Count > 0);
|
||||
}
|
||||
|
||||
@@ -68,7 +77,8 @@ public static class ConvertPlans
|
||||
|
||||
/// <summary>
|
||||
/// "12 of 36 change · 3,600 photos · 41 GB → 32 GB · 20 skipped": the sequences converted of those planned, then the
|
||||
/// photos and their sizes when something converts, the photos skipped when there are any.
|
||||
/// photos and their sizes when something converts, the photos skipped when there are any ("20 not copied" with
|
||||
/// <see cref="ConvertMode.NewSequence"/>: the new sequences lack them).
|
||||
/// </summary>
|
||||
public static string Summary(ConvertPlan plan)
|
||||
{
|
||||
@@ -79,7 +89,8 @@ public static class ConvertPlans
|
||||
parts.Add(Loc.Plural("Shell.Status.Photos", plan.Frames));
|
||||
parts.Add(Sizes(plan.BytesBefore, plan.BytesAfter));
|
||||
}
|
||||
if (plan.Skipped > 0) parts.Add(Loc.Plural("Archive.Convert.SkippedPhotos", plan.Skipped));
|
||||
if (plan.Skipped > 0)
|
||||
parts.Add(Loc.Plural(plan.Mode == ConvertMode.NewSequence ? "Archive.Convert.NotCopiedPhotos" : "Archive.Convert.SkippedPhotos", plan.Skipped));
|
||||
return string.Join(Loc.Separator, parts);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user