From d37b9158bb7c755cf2b3723fa78287532514e02b Mon Sep 17 00:00:00 2001 From: Alexander Renz Date: Tue, 31 Dec 2024 07:10:25 +0100 Subject: [PATCH] fix: add nil checks for redis client and thumbnail paths in verifyAndRepairThumbnails function --- cmd/server/main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/server/main.go b/cmd/server/main.go index 57039a7..6b9bb55 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -3091,6 +3091,18 @@ func handleThumbnails(w http.ResponseWriter, r *http.Request) { // verifyAndRepairThumbnails verifies the integrity of thumbnail files and repairs them if necessary func verifyAndRepairThumbnails(thumbnailPaths []string, redisClient *redis.Client, originalDir string) { + // Check if redisClient is nil + if redisClient == nil { + log.Error("Redis client is nil. Cannot verify and repair thumbnails.") + return + } + + // Check if thumbnailPaths is nil or empty + if len(thumbnailPaths) == 0 { + log.Error("Thumbnail paths are nil or empty. Nothing to verify or repair.") + return + } + for _, thumbPath := range thumbnailPaths { // Compute SHA-256 hash of the thumbnail file file, err := os.Open(thumbPath)