Unione delle correzioni di importazione e dati
Conflitti in LibraryIngest e DownloadQueue risolti tenendo entrambe le correzioni: il cancello per cartella dell'account (dedup-1), l'elemento eliminato durante lo scaricamento (library-2) e la registrazione separata in RecordAsync, insieme al file sempre registrato una volta col nome finale (library-1), alle righe di _febe.jsonl in sospeso scritte più tardi e alla riga scritta dopo ogni esito finale (journal-1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
13 files changed
+1148
-95
No files matched your search
@@ -222,6 +222,8 @@ public sealed class DownloadQueue
|
||||
/// </summary>
|
||||
public async Task<DownloadReport> RunOnceAsync(CancellationToken ct)
|
||||
{
|
||||
// Lines a busy _febe.jsonl refused earlier: local work, written also while the CDN or the connection says to wait.
|
||||
await _ingest.AppendPendingJournalAsync(ct).ConfigureAwait(false);
|
||||
var tally = new Tally();
|
||||
if (PausedUntil is { } paused)
|
||||
{
|
||||
@@ -305,6 +307,16 @@ public sealed class DownloadQueue
|
||||
}
|
||||
|
||||
private async Task ProcessAsync(PendingDownload pending, Tally tally, ConcurrentDictionary<long, Account?> accounts, ConcurrentDictionary<long, bool> singlePostQueued, CancellationToken ct)
|
||||
{
|
||||
await ProcessFileAsync(pending, tally, accounts, singlePostQueued, ct).ConfigureAwait(false);
|
||||
|
||||
// Whatever the outcome (stored, duplicate, skipped, failed), the entry may now be settled: its journal line is
|
||||
// written once no file waits any more and at least one is in the library (spec §8.5). A deleted entry gets
|
||||
// none (LibraryIngest.AppendJournalAsync): a «save» line after its «delete» line would bring it back.
|
||||
await AppendJournalWhenSettledAsync(pending.Media.EntryId).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task ProcessFileAsync(PendingDownload pending, Tally tally, ConcurrentDictionary<long, Account?> accounts, ConcurrentDictionary<long, bool> singlePostQueued, CancellationToken ct)
|
||||
{
|
||||
if (!accounts.TryGetValue(pending.AccountId, out var account))
|
||||
{
|
||||
@@ -515,7 +527,6 @@ public sealed class DownloadQueue
|
||||
{
|
||||
tally.Add(ref tally.Stored);
|
||||
Report(media, entry, DownloadStep.Stored);
|
||||
await AppendJournalWhenCompleteAsync(entry, ct).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -607,12 +618,17 @@ public sealed class DownloadQueue
|
||||
Report(media, entry, DownloadStep.Expired);
|
||||
}
|
||||
|
||||
private async Task AppendJournalWhenCompleteAsync(Entry entry, CancellationToken ct)
|
||||
/// <summary>
|
||||
/// Appends the journal line of an entry once settled. A journal that cannot be written now (a sync client holding
|
||||
/// <c>_febe.jsonl</c>, a share that dropped) never turns a stored file back into one to download: the line waits
|
||||
/// in <see cref="LibraryIngest.TryAppendJournalAsync"/> and is written by a later pass.
|
||||
/// </summary>
|
||||
private async Task AppendJournalWhenSettledAsync(long entryId)
|
||||
{
|
||||
var files = await _storage.Media.ListByEntryAsync(entry.Id, ct).ConfigureAwait(false);
|
||||
if (files.All(f => f.State is not (MediaState.ToDownload or MediaState.Expired)))
|
||||
var files = await _storage.Media.ListByEntryAsync(entryId, CancellationToken.None).ConfigureAwait(false);
|
||||
if (files.Any(f => EntryStateRules.IsPresent(f.State)) && files.All(f => f.State is not (MediaState.ToDownload or MediaState.Expired)))
|
||||
{
|
||||
await _ingest.AppendJournalAsync(entry.Id, ct).ConfigureAwait(false);
|
||||
await _ingest.TryAppendJournalAsync(entryId, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user