| | | 1 | | using Anichron.Core.Domain; |
| | | 2 | | using Anichron.Worker.Ingestion.Extraction; |
| | | 3 | | using Anichron.Worker.Ingestion.Pipeline; |
| | | 4 | | using Anichron.Worker.Ingestion.Proxy; |
| | | 5 | | |
| | | 6 | | namespace Anichron.Worker.Ingestion.Classification; |
| | | 7 | | |
| | | 8 | | internal sealed partial class ContentChangedWriter( |
| | | 9 | | StoredContent storedContent, |
| | | 10 | | PairedMovResolver pairedMovResolver, |
| | | 11 | | PairedMovProxyWriter pairedMovProxyWriter, |
| | | 12 | | CaptureZones captureZones, |
| | | 13 | | ILogger<ContentChangedWriter> logger) |
| | 21 | 14 | | : ProcessedContentWriter(pairedMovResolver, pairedMovProxyWriter, captureZones) |
| | | 15 | | { |
| | 21 | 16 | | public override IReadOnlyCollection<FileOutcome> Outcomes => [FileOutcome.ContentChanged, FileOutcome.AutoRestoredCo |
| | | 17 | | |
| | | 18 | | protected override async Task<MediaAsset> WriteAssetAsync(IngestionContext context, CancellationToken ct) |
| | 20 | 19 | | { |
| | 20 | 20 | | var asset = context.Classification!.Primary.Stored!; |
| | 20 | 21 | | Log.ContentChanged(logger, asset.Id, context.Item.RelativePath, asset.ContentHash, context.ContentHash!); |
| | | 22 | | |
| | 20 | 23 | | var content = ContentOf(context, asset.Id); |
| | 20 | 24 | | if (await storedContent.TakeAsync(context, asset, content with { Captured = content.Captured ?? asset.Captured } |
| | 2 | 25 | | Log.AutoRestored(logger, asset.Id, context.Item.RelativePath); |
| | | 26 | | |
| | 20 | 27 | | return asset; |
| | 20 | 28 | | } |
| | | 29 | | |
| | | 30 | | private static partial class Log |
| | | 31 | | { |
| | | 32 | | [LoggerMessage(Level = LogLevel.Information, Message = "Asset {AssetId} at {RelativePath} changed content from { |
| | | 33 | | public static partial void ContentChanged(ILogger logger, Guid assetId, string relativePath, string oldHash, str |
| | | 34 | | |
| | | 35 | | [LoggerMessage(Level = LogLevel.Debug, Message = "Auto-restored asset {AssetId} at {RelativePath} with its new c |
| | | 36 | | public static partial void AutoRestored(ILogger logger, Guid assetId, string relativePath); |
| | | 37 | | } |
| | | 38 | | } |