< Summary

Information
Class: Anichron.API.Infrastructure.OriginalsStorageHealthCheck
Assembly: Anichron.API
File(s): /home/runner/work/anichron/anichron/src/Anichron.API/Infrastructure/OriginalsStorageHealthCheck.cs
Tag: 19_45211875487
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 30
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
CheckHealthAsync(...)100%22100%

File(s)

/home/runner/work/anichron/anichron/src/Anichron.API/Infrastructure/OriginalsStorageHealthCheck.cs

#LineLine coverage
 1using Anichron.Infrastructure.Storage;
 2using Microsoft.Extensions.Diagnostics.HealthChecks;
 3
 4namespace Anichron.API.Infrastructure;
 5
 6// Mirrors ProxyStorageHealthCheck for the originals mount. Both exist because the two stores
 7// fail independently: proxies are local SSD, originals are the NAS.
 8//
 9// ⚠️ Degraded, not Unhealthy, when the directory is missing. A vanished NAS mount stops
 10// on-demand serving of originals, but proxies and every other endpoint keep working — so
 11// reporting Unhealthy would pull the whole API out of rotation for a partial loss of function.
 12// A THROWING store is a different condition (unreadable or hung mount rather than absent)
 13// and does report Unhealthy, carrying the exception for diagnosis.
 414internal sealed class OriginalsStorageHealthCheck(IOriginalStore store) : IHealthCheck
 15{
 16    public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = de
 317    {
 18        try
 319        {
 320            return Task.FromResult(
 321                store.RootExists()
 322                    ? HealthCheckResult.Healthy("Originals storage directory found.")
 323                    : HealthCheckResult.Degraded("Originals storage directory not found."));
 24        }
 125        catch (Exception ex)
 126        {
 127            return Task.FromResult(HealthCheckResult.Unhealthy("Originals storage check failed.", ex));
 28        }
 329    }
 30}