Files
Libation/Source/LibationUiBase/ProcessQueue/BadBookSessionContext.cs
T
Allamagoosa 76e036fb42 Report the abort on the book the user answered for
With several books in flight, the book whose dialog was answered showed
"Cancelled" while some unrelated book showed "Error, Abort". Tearing the queue
down is claimed by whichever book finishes first, and the books genuinely are
interchangeable for that. The status left on a row is not: it is read afterwards
by someone who remembers which book they were asked about.

The two jobs are now separate. ShowRetryDialogAsync records the answering book as
BadBookSessionContext.AbortOriginator, written before Override so that a book
reading Override and racing ahead to the queue loop cannot find the originator
still unset and conclude there was none. The loop gives the abort to that book and
Cancelled to every book that inherited the answer. ClaimAbort is unchanged and
still decides the teardown.

With no dialog in play - Bad Book set to Abort in settings - nobody answered
anything, there is no originator, and the book that claimed the teardown keeps the
abort as before.
2026-08-24 10:02:46 -07:00

36 lines
1.3 KiB
C#

using System.Threading;
using LibationFileManager;
namespace LibationUiBase.ProcessQueue;
public class BadBookSessionContext
{
public Configuration.BadBookAction? Override { get; set; }
/// <summary>
/// Serialises the "skip this book?" dialog. Several books can now fail at the same time, and the
/// answer to one of them may be "apply to all remaining books" - which has to be recorded before
/// the next book decides whether it still needs to ask.
/// </summary>
internal SemaphoreSlim DialogGate { get; } = new(1, 1);
/// <summary>
/// The book the user actually answered "Abort" for, when one was asked. Null when the abort came
/// from the Bad Book setting rather than a dialog, and null when nothing has aborted.
/// </summary>
/// <remarks>
/// Recorded because tearing the queue down and reporting the abort are different jobs. The
/// teardown is claimed by whichever book finishes first and the books are interchangeable for
/// it; the status left on a row is read afterwards by a person who remembers which book they
/// were asked about, and "Cancelled" on that row with "Error, Abort" on some other book's is
/// the wrong way round.
/// </remarks>
public ProcessBookViewModel? AbortOriginator { get; set; }
public void Reset()
{
Override = null;
AbortOriginator = null;
}
}