diff --git a/thumbnail/thumbnail.go b/thumbnail/thumbnail.go index b5e5379..d5203c1 100644 --- a/thumbnail/thumbnail.go +++ b/thumbnail/thumbnail.go @@ -72,6 +72,14 @@ func GetThumbnail(c *fiber.Ctx, completePath string) { return } WaitForAvailable() + /* While waiting some other thread could have generated the thumbnail */ + thumbnailCacheMutex.RLock() + bytesThumb, ok = thumbnailCache[completePath] + thumbnailCacheMutex.RUnlock() + if ok { + c.Write(bytesThumb) + return + } fileExt := filepath.Ext(completePath) if !slices.Contains(SupportedFileTypes, fileExt) {