Skip to content

Commit

Permalink
fix: add nil checks for redis client and thumbnail paths in verifyAnd…
Browse files Browse the repository at this point in the history
…RepairThumbnails function
  • Loading branch information
PlusOne committed Dec 31, 2024
1 parent a777c7a commit d37b915
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d37b915

Please sign in to comment.