< Summary

Line coverage
100%
Covered lines: 28
Uncovered lines: 0
Coverable lines: 28
Total lines: 1016
Line coverage: 100%
Branch coverage
100%
Covered branches: 12
Total branches: 12
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: .cctor()100%11100%
File 2: .ctor(...)100%11100%
File 2: get_Order()100%11100%
File 2: CanInvoke(...)100%11100%
File 2: InvokeAsync()100%1010100%
File 2: ReconcileSecondaryAsync()100%22100%

File(s)

/home/runner/work/anichron/anichron/src/.artifacts/obj/Anichron.Worker/debug/Microsoft.Extensions.Logging.Generators/Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator/LoggerMessage.g.cs

File '/home/runner/work/anichron/anichron/src/.artifacts/obj/Anichron.Worker/debug/Microsoft.Extensions.Logging.Generators/Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator/LoggerMessage.g.cs' does not exist (any more).

/home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Middlewares/ClassificationMiddleware.cs

#LineLine coverage
 1using Anichron.Worker.Ingestion.Classification;
 2using Anichron.Worker.Ingestion.Pipeline;
 3
 4namespace Anichron.Worker.Ingestion.Middlewares;
 5
 576internal sealed partial class ClassificationMiddleware(
 577    IngestionClassifier classifier,
 578    LivePhotoPairer pairer,
 579    KnownFileReconciler reconciler,
 5710    IngestionSaver saver,
 5711    ILogger<ClassificationMiddleware> logger) : IIngestionMiddleware
 12{
 113    public int Order => IngestionOrder.Classification;
 314    public bool CanInvoke(IngestionContext context) => true;
 15
 16    public async Task InvokeAsync(IngestionContext context, IngestionDelegate next, CancellationToken ct)
 5517    {
 5518        var classification = await classifier.ClassifyAsync(context, ct);
 5519        context.Classification = classification;
 5520        context.AssetId = classification.Primary.Stored?.Id ?? context.AttemptId;
 5521        if (classification.NeedsProcessing)
 722        {
 723            await ReconcileSecondaryAsync(context, classification, ct);
 724            await next(context, ct);
 725            return;
 26        }
 27
 4828        await pairer.PairAsync(context, classification, ct);
 29
 4830        var changed = await reconciler.ReconcileAsync(context, classification.Primary, context.Item.RelativePath, ct);
 4831        if (await ReconcileSecondaryAsync(context, classification, ct))
 2232            changed = true;
 33
 4834        if (changed && !await saver.TrySaveItemAsync(context, null, ct))
 235            Log.ContentTakenConcurrently(logger, context.Item.RelativePath);
 4836    }
 37
 38    private async Task<bool> ReconcileSecondaryAsync(
 39        IngestionContext context, IngestionClassification classification, CancellationToken ct)
 5540        => classification.Secondary is { } secondary
 5541            && await reconciler.ReconcileSecondaryAsync(context, secondary, classification.Primary, context.Item.Seconda
 42
 43    private static partial class Log
 44    {
 45        [LoggerMessage(
 46            Level = LogLevel.Debug,
 47            Message = "Another consumer took the content now at {RelativePath} first, skipping; the next crawl reconcile
 48        public static partial void ContentTakenConcurrently(ILogger logger, string relativePath);
 49    }
 50}