fix: add empty catch comment and SingleOrDefault safety (#99)

Co-authored-by: admin <admin@ardentleatherworks.com>
This commit is contained in:
Cody Kickertz 2025-12-21 11:59:59 -06:00 committed by GitHub
parent 1a5ca83f4f
commit b843e777de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -86,6 +86,7 @@ protected virtual string GetInfoHash(XElement item)
}
catch
{
// Invalid magnet URL format - fall through to return null
}
}

View file

@ -35,7 +35,13 @@ public string AddCacheBreakerToPath(string resourceUrl)
return resourceUrl + "?t=" + DateTime.UtcNow.Ticks;
}
var mapper = _diskMappers.Single(m => m.CanHandle(resourceUrl));
var mapper = _diskMappers.SingleOrDefault(m => m.CanHandle(resourceUrl));
if (mapper == null)
{
return resourceUrl;
}
var pathToFile = mapper.Map(resourceUrl);
var hash = _hashProvider.ComputeMd5(pathToFile).ToBase64();