| | | 1 | | using Anichron.Core.Domain; |
| | | 2 | | |
| | | 3 | | namespace Anichron.Worker.Ingestion.Pipeline; |
| | | 4 | | |
| | | 5 | | internal sealed class IngestionContext |
| | | 6 | | { |
| | 116 | 7 | | private readonly List<ProxyFile> proxyFiles = []; |
| | 116 | 8 | | private readonly Lock proxyFilesLock = new(); |
| | | 9 | | |
| | | 10 | | public required IngestionItem Item { get; init; } |
| | | 11 | | public required UserStorageConfig Config { get; init; } |
| | | 12 | | |
| | | 13 | | public required Guid AssetId { get; init; } |
| | | 14 | | |
| | | 15 | | public string? ContentHash { get; set; } |
| | | 16 | | public string? SecondaryHash { get; set; } |
| | | 17 | | public ExifData? Exif { get; set; } |
| | | 18 | | public MediaAsset? Asset { get; set; } |
| | | 19 | | |
| | | 20 | | // Records what this attempt has actually put on disk: each proxy registers itself the |
| | | 21 | | // moment it is renamed into place, so compensation on failure can delete precisely those |
| | | 22 | | // files. Image proxies are generated concurrently, hence the lock and the snapshot. |
| | | 23 | | public IReadOnlyList<ProxyFile> ProxyFiles |
| | | 24 | | { |
| | | 25 | | get |
| | 50 | 26 | | { |
| | | 27 | | lock (proxyFilesLock) |
| | 50 | 28 | | return [.. proxyFiles]; |
| | 50 | 29 | | } |
| | | 30 | | } |
| | | 31 | | |
| | | 32 | | public void AddProxyFile(ProxyFile proxyFile) |
| | 88 | 33 | | { |
| | | 34 | | lock (proxyFilesLock) |
| | 88 | 35 | | proxyFiles.Add(proxyFile); |
| | 88 | 36 | | } |
| | | 37 | | } |