From 6859f3ebbca667642f995235560e0ab172fada5b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 24 May 2018 17:18:33 -0400 Subject: [PATCH] cache not found --- src/Icons/Controllers/IconsController.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Icons/Controllers/IconsController.cs b/src/Icons/Controllers/IconsController.cs index 350af4111b..e414d67ec1 100644 --- a/src/Icons/Controllers/IconsController.cs +++ b/src/Icons/Controllers/IconsController.cs @@ -48,13 +48,15 @@ namespace Bit.Icons.Controllers var result = await _iconFetchingService.GetIconAsync(mappedDomain); if(result == null) { - return new NotFoundResult(); + icon = null; + } + else + { + icon = result.Icon; } - icon = result.Icon; - - // Only cache smaller images (<= 50kb) - if(icon.Image.Length <= 50012) + // Only cache not found and smaller images (<= 50kb) + if(icon == null || icon.Image.Length <= 50012) { _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); } }