Subsonic API: getCoverArt: serve raw image if size is not provided

This commit is contained in:
emeric
2024-12-07 18:27:01 +01:00
parent 350e213529
commit def4d8c3e3
25 changed files with 305 additions and 372 deletions
+11 -3
View File
@@ -33,21 +33,29 @@ namespace lms::cover
void ImageCache::addImage(const EntryDesc& entryDesc, std::shared_ptr<image::IEncodedImage> image)
{
// cache only resized files
if (!entryDesc.size)
return;
const std::unique_lock lock{ _mutex };
while (_cacheSize + image->getDataSize() > _maxCacheSize && !_cache.empty())
while (_cacheSize + image->getData().size() > _maxCacheSize && !_cache.empty())
{
auto itRandom{ core::random::pickRandom(_cache) };
_cacheSize -= itRandom->second->getDataSize();
_cacheSize -= itRandom->second->getData().size();
_cache.erase(itRandom);
}
_cacheSize += image->getDataSize();
_cacheSize += image->getData().size();
_cache[entryDesc] = image;
}
std::shared_ptr<image::IEncodedImage> ImageCache::getImage(const EntryDesc& entryDesc) const
{
// cache only resized files
if (!entryDesc.size)
return {};
const std::shared_lock lock{ _mutex };
const auto it{ _cache.find(entryDesc) };