L'ordine dei tipi (storie, evidenza, post, reel, taggati) ora vale anche per il singolo account: nella scheda account → Impostazioni si sceglie «Come le impostazioni generali» o un ordine suo, con lo stesso elenco da trascinare (o Su/Giù da tastiera) di Limiti e comportamento, ora un modulo solo (download-order.js). Il motore pesa le visite con l'ordine dell'account, la coda dei file mette ogni file al posto del suo tipo nell'ordine del suo account, stabile dentro il tipo (scadenza, scoperta, elemento, posizione). Perché nessun tipo resti fermo per sempre quando il tetto dei dati finisce prima della coda, un posto su otto di ogni giro della coda va al file che aspetta da più tempo, di qualunque tipo. I reel non si inventano (regola 9): un post è reel se viene dalla scheda Reel o se la risposta ha product_type «clips», valore visto nei campioni ripuliti. Il segno si scrive da solo e non si toglie mai, così una copia vecchia non sposta di nuovo i file in coda. Migrazione 0002_ordine_scaricamento (account.download_order, entry.is_reel): prende il primo numero dopo quelle unite, E1 userà il successivo. Prove su motore (seme fisso), coda, lettori, ricette e API; dimostrazione con un account che ha l'ordine suo; guida e decisioni aggiornate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
4.5 KiB
C#
78 lines
4.5 KiB
C#
using Febe.Core.Domain;
|
|
|
|
namespace Febe.Core.Storage;
|
|
|
|
/// <summary>Files of entries (spec §8.3 <c>media</c>), hashes and the download queue.</summary>
|
|
public interface IMediaStore
|
|
{
|
|
Task<Media?> GetAsync(long mediaId, CancellationToken ct = default);
|
|
|
|
/// <summary>Files of an entry in position order.</summary>
|
|
Task<IReadOnlyList<Media>> ListByEntryAsync(long entryId, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Every file with this SHA-256 across the whole library, any state, with its entry and account
|
|
/// («Già in libreria», spec §9.3; exact duplicates after a download, §9.5).
|
|
/// </summary>
|
|
Task<IReadOnlyList<MediaLocation>> FindBySha256Async(string sha256, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Relative paths of the files of an account that have one, with their entry: recognizes entries without an
|
|
/// Instagram identifier (imported) by their files (rebuild, import resume).
|
|
/// </summary>
|
|
Task<IReadOnlyDictionary<string, long>> MapPathsAsync(long accountId, CancellationToken ct = default);
|
|
|
|
/// <summary>Perceptual hashes of the photos present in the library, to load the in-memory index.</summary>
|
|
Task<IReadOnlyList<PerceptualHashRecord>> LoadPerceptualHashesAsync(CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Files waiting to be downloaded, in queue order: stories first (they expire), then by expiry and discovery.
|
|
/// </summary>
|
|
Task<IReadOnlyList<PendingDownload>> ListPendingDownloadsAsync(int limit, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Files waiting to be downloaded in the order of «Cosa scaricare prima» (spec §6.5, §7.2): for each file the position
|
|
/// of its kind (a post Febe knows to be a reel counts as a reel) in the order of its account, which is the account's
|
|
/// own when it has one, else the general one; within a position the ones that expire first, then the oldest
|
|
/// waiting, then entry and position (stable).
|
|
/// </summary>
|
|
Task<IReadOnlyList<PendingDownload>> ListPendingDownloadsAsync(int limit, DownloadQueueOrder order, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Files waiting to be downloaded, the longest waiting first (discovery, then entry and position), whatever their
|
|
/// kind: the share of the queue that keeps the later kinds of «Cosa scaricare prima» from waiting for ever.
|
|
/// </summary>
|
|
Task<IReadOnlyList<PendingDownload>> ListLongestWaitingDownloadsAsync(int limit, CancellationToken ct = default);
|
|
|
|
/// <summary>Files waiting to be downloaded, for one account or overall («lo storico non corre più veloce dei download»).</summary>
|
|
Task<int> CountPendingDownloadsAsync(long? accountId = null, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Records a file now on disk and recomputes the state of its entry, in one transaction. Returns false, changing
|
|
/// nothing, when the file or its entry is «eliminato» (Alberto deleted it while the content was on its way): the
|
|
/// caller removes the file it just wrote. Throws <see cref="KeyNotFoundException"/> when the file record is gone.
|
|
/// </summary>
|
|
Task<bool> MarkStoredAsync(long mediaId, StoredFile file, MediaState state, DateTimeOffset at, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Records a failed attempt: <paramref name="state"/> is Failed, Expired (address expired) or Skipped (a limit).
|
|
/// Increments attempts and recomputes the state of the entry.
|
|
/// </summary>
|
|
Task MarkFailedAsync(long mediaId, MediaState state, string? error, DateTimeOffset at, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Adds files to an existing entry at positions it does not have yet (files at positions already present are left
|
|
/// as they are) and recomputes the state of the entry. Used by «Post singolo» to complete a series that arrived
|
|
/// incomplete. Returns the files of the entry in position order.
|
|
/// </summary>
|
|
Task<IReadOnlyList<Media>> AddToEntryAsync(long entryId, IReadOnlyList<Media> media, CancellationToken ct = default);
|
|
|
|
/// <summary>A fresh address read from the page: the file goes back to «da scaricare».</summary>
|
|
Task UpdateSourceAsync(long mediaId, string? sourceUrl, string? coverUrl, DateTimeOffset seenAt, CancellationToken ct = default);
|
|
|
|
Task SetThumbnailAsync(long mediaId, bool hasThumbnail, CancellationToken ct = default);
|
|
|
|
/// <summary>Replaces every field of a file record.</summary>
|
|
Task UpdateAsync(Media media, CancellationToken ct = default);
|
|
}
|