1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-22 20:11:04 -05:00

cache not found

This commit is contained in:
Kyle Spearrin 2018-05-24 17:18:33 -04:00
parent 72e95e2a98
commit 6859f3ebbc

View File

@ -48,13 +48,15 @@ namespace Bit.Icons.Controllers
var result = await _iconFetchingService.GetIconAsync(mappedDomain); var result = await _iconFetchingService.GetIconAsync(mappedDomain);
if(result == null) if(result == null)
{ {
return new NotFoundResult(); icon = null;
}
else
{
icon = result.Icon;
} }
icon = result.Icon; // Only cache not found and smaller images (<= 50kb)
if(icon == null || icon.Image.Length <= 50012)
// Only cache smaller images (<= 50kb)
if(icon.Image.Length <= 50012)
{ {
_memoryCache.Set(mappedDomain, icon, new MemoryCacheEntryOptions _memoryCache.Set(mappedDomain, icon, new MemoryCacheEntryOptions
{ {
@ -63,6 +65,11 @@ namespace Bit.Icons.Controllers
} }
} }
if(icon == null)
{
return new NotFoundResult();
}
return new FileContentResult(icon.Image, icon.Format); return new FileContentResult(icon.Image, icon.Format);
} }
} }