Skip to content

Commit

Permalink
fix: enhance logging for Redis operations and improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
PlusOne committed Dec 31, 2024
1 parent 6d2a168 commit eb42034
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2727,7 +2727,7 @@ func precacheStoragePath(dir string) error {
data, err := redisClient.Get(context.Background(), "directory_index").Result()
if err == nil {
var index []FileMetadata
err = json.Unmarshal([]byte(data), &index) // Added the target variable
err = json.Unmarshal([]byte(data), &index)
if err == nil {
for _, metadata := range index {
fileInfoCache.Set(metadata.FilePath, metadata.FileInfo, cache.DefaultExpiration)
Expand All @@ -2736,9 +2736,9 @@ func precacheStoragePath(dir string) error {
log.Info("Loaded directory index from Redis")
return nil
}
log.Warn("Failed to unmarshal directory index from Redis")
log.Warnf("Failed to unmarshal directory index from Redis: %v", err)
} else {
log.Warn("Failed to load directory index from Redis:", err)
log.Warnf("Failed to load directory index from Redis: %v", err)
}
}

Expand All @@ -2758,9 +2758,9 @@ func precacheStoragePath(dir string) error {
log.Info("Loaded directory index from static index file")
return nil
}
log.Warn("Failed to decode static index file:", err)
log.Warnf("Failed to decode static index file: %v", err)
} else {
log.Warn("Static index file not found:", err)
log.Warnf("Static index file not found: %v", err)
}

// Perform full directory scan
Expand Down Expand Up @@ -2793,10 +2793,10 @@ func precacheStoragePath(dir string) error {
if err == nil {
log.Info("Saved directory index to Redis")
} else {
log.Warn("Failed to save directory index to Redis:", err)
log.Warnf("Failed to save directory index to Redis: %v", err)
}
} else {
log.Warn("Failed to marshal directory index for Redis:", err)
log.Warnf("Failed to marshal directory index for Redis: %v", err)
}
}

Expand All @@ -2809,10 +2809,10 @@ func precacheStoragePath(dir string) error {
if err == nil {
log.Info("Saved directory index to static index file")
} else {
log.Warn("Failed to encode directory index to static index file:", err)
log.Warnf("Failed to encode directory index to static index file: %v", err)
}
} else {
log.Warn("Failed to create static index file:", err)
log.Warnf("Failed to create static index file: %v", err)
}

// Monitor directory for changes
Expand Down Expand Up @@ -2861,7 +2861,7 @@ func monitorDirectoryChanges(dir string) {

func generateThumbnail(originalPath, size string) error {
// Check if thumbnail generation is enabled
if !conf.Thumbnails.Enabled {
if (!conf.Thumbnails.Enabled) {
log.Debug("Thumbnail generation is disabled")
return nil
}
Expand Down

0 comments on commit eb42034

Please sign in to comment.