fix: while waiting some other thread could have generated the thumbnail

This commit is contained in:
Louis Dalibard 2024-06-10 22:25:05 +02:00
parent 28d526ab74
commit c148adb225

View File

@ -72,6 +72,14 @@ func GetThumbnail(c *fiber.Ctx, completePath string) {
return return
} }
WaitForAvailable() 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) fileExt := filepath.Ext(completePath)
if !slices.Contains(SupportedFileTypes, fileExt) { if !slices.Contains(SupportedFileTypes, fileExt) {