< Summary

Information
Class: Anichron.Worker.Ingestion.Proxy.TwoLevelHexShardStrategy
Assembly: Anichron.Worker
File(s): /home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Proxy/ProxyShardStrategy.cs
Tag: 228_36821334185
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 18
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetDirectory(...)100%11100%

File(s)

/home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Proxy/ProxyShardStrategy.cs

#LineLine coverage
 1namespace Anichron.Worker.Ingestion.Proxy;
 2
 3internal interface IProxyDirectoryStrategy
 4{
 5    string GetDirectory(Guid storageConfigId, string contentHash);
 6}
 7
 8internal sealed class TwoLevelHexShardStrategy : IProxyDirectoryStrategy
 9{
 10    // Derived from content rather than from the ingestion attempt, so a retry of a failed
 11    // file lands in the same directory and overwrites its own debris instead of stranding it.
 12    // Two hex chars of the content hash → 256 top-level buckets; prevents filesystem
 13    // directory-count blowup at large library sizes. The storage config id keeps byte-identical
 14    // files of different users apart — without it, removing one user's config would cascade
 15    // away the other user's proxies.
 16    public string GetDirectory(Guid storageConfigId, string contentHash)
 617        => $"{contentHash[..2]}/{storageConfigId:N}-{contentHash}";
 18}