< Summary

Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 62
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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: Read(...)100%11100%
File 2: Describe(...)100%44100%

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/Bursts/OriginalPhotoReader.cs

#LineLine coverage
 1using MetadataExtractor;
 2using MetadataExtractor.Formats.Exif.Makernotes;
 3using System.IO.Abstractions;
 4
 5namespace Anichron.Worker.Bursts;
 6
 7/// <summary>What burst detection reads from a photo's original.</summary>
 8/// <param name="CameraBurstId">Apple's BurstUUID, or null when the camera wrote none.</param>
 9internal sealed record OriginalPhotoFacts(string? CameraBurstId)
 10{
 11    internal static OriginalPhotoFacts Unknown { get; } = new(CameraBurstId: null);
 12}
 13
 14internal interface IOriginalPhotoReader
 15{
 16    /// <summary>Reads the original once; an unreadable one is logged and yields no facts.</summary>
 17    /// <param name="absolutePath">The original's path in the container.</param>
 18    OriginalPhotoFacts Read(string absolutePath);
 19}
 20
 321internal sealed partial class OriginalPhotoReader(IFileSystem fileSystem, ILogger<OriginalPhotoReader> logger)
 22    : IOriginalPhotoReader
 23{
 24    public OriginalPhotoFacts Read(string absolutePath)
 225    {
 26        try
 227        {
 228            using var stream = fileSystem.File.OpenRead(absolutePath);
 129            return Describe(ImageMetadataReader.ReadMetadata(stream));
 30        }
 131        catch (Exception ex)
 132        {
 133            Log.Unreadable(logger, absolutePath, ex);
 134            return OriginalPhotoFacts.Unknown;
 35        }
 236    }
 37
 38    internal static OriginalPhotoFacts Describe(IReadOnlyList<MetadataExtractor.Directory> directories)
 539    {
 540        var burstId = directories.OfType<AppleMakernoteDirectory>().FirstOrDefault()?.GetString(AppleMakernoteDirectory.
 541        return new(string.IsNullOrWhiteSpace(burstId) ? null : burstId);
 542    }
 43
 44    private static partial class Log
 45    {
 46        [LoggerMessage(Level = LogLevel.Warning, Message = "Could not read {Path} for burst detection; it is grouped by 
 47        public static partial void Unreadable(ILogger logger, string path, Exception exception);
 48    }
 49}