Files
Febe/src/Febe.Core/Storage/IMediaStore.cs
T
Claude 3aeaa17da7 M1 Dati e libreria: modello, archivi SQLite con scrittore unico, nomi dei file, scrittura sicura, miniature, impronte, _febe.jsonl, copie, eliminazione e ricostruzione
Modello del dominio e interfacce degli archivi in Febe.Core; implementazione SQLite in Febe.Data (WAL, chiavi esterne, migrazioni numerate in transazione, coda di scrittura su un solo thread); logica della libreria in Febe.Core/Library; 164 prove MSTest, compresa la ricostruzione del database da una libreria di prova e la scala a 200.000 elementi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
2026-10-13 16:06:15 +00:00

53 lines
2.8 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, 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.</summary>
Task 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>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);
}