fix: correct UUID format string issues in logging and tests
- Fix scheduler.go log.Printf calls to convert pgtype.UUID to string before formatting - Fix ebook.go fmt.Printf calls to convert pgtype.UUID to string before formatting - Add missing Enabled field to rate limiter config in security test - Prevents format string errors when logging library IDs This resolves compilation errors where pgtype.UUID was being formatted with %s which expects a string, not a UUID struct.
This commit is contained in:
@@ -87,6 +87,7 @@ func TestRateLimiterSecurity(t *testing.T) {
|
|||||||
e := echo.New()
|
e := echo.New()
|
||||||
|
|
||||||
config := ratelimit.RateLimiterConfig{
|
config := ratelimit.RateLimiterConfig{
|
||||||
|
Enabled: true,
|
||||||
RequestsPerMinute: 3,
|
RequestsPerMinute: 3,
|
||||||
CleanupInterval: 1 * time.Minute,
|
CleanupInterval: 1 * time.Minute,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -797,11 +797,12 @@ func (h *Handler) StartWatchModeForAllLibraries(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, library := range libraries {
|
for _, library := range libraries {
|
||||||
|
libraryIDStr := fmt.Sprintf("%x", library.ID.Bytes)
|
||||||
if err := h.StartWatchModeForLibrary(ctx, library.ID, library.ID); err != nil {
|
if err := h.StartWatchModeForLibrary(ctx, library.ID, library.ID); err != nil {
|
||||||
fmt.Printf("Warning: failed to start watch mode for library %s: %v\n", library.ID, err)
|
fmt.Printf("Warning: failed to start watch mode for library %s: %v\n", libraryIDStr, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Printf("Started watch mode for library %s (%s)\n", library.Name, library.ID)
|
fmt.Printf("Started watch mode for library %s (%s)\n", library.Name, libraryIDStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ func (s *Scheduler) checkAndScheduleScans() {
|
|||||||
for _, library := range libraries {
|
for _, library := range libraries {
|
||||||
settings, err := s.db.GetScanSettings(ctx, library.ID)
|
settings, err := s.db.GetScanSettings(ctx, library.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error getting scan settings for library %s: %v", library.ID, err)
|
libraryIDStr := fmt.Sprintf("%x", library.ID.Bytes)
|
||||||
|
log.Printf("Error getting scan settings for library %s: %v", libraryIDStr, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,20 +157,22 @@ func (s *Scheduler) scheduleLibraryScan(ctx context.Context, libraryID pgtype.UU
|
|||||||
|
|
||||||
s.timers[timerID] = timer
|
s.timers[timerID] = timer
|
||||||
|
|
||||||
log.Printf("Scheduled scan for library %s every %d minutes", libraryID, frequencyMinutes)
|
libraryIDStr := fmt.Sprintf("%x", libraryID.Bytes)
|
||||||
|
log.Printf("Scheduled scan for library %s every %d minutes", libraryIDStr, frequencyMinutes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scheduler) triggerScheduledScan(ctx context.Context, libraryID pgtype.UUID, userID string) {
|
func (s *Scheduler) triggerScheduledScan(ctx context.Context, libraryID pgtype.UUID, userID string) {
|
||||||
log.Printf("Triggering scheduled scan for library %s", libraryID)
|
libraryIDStr := fmt.Sprintf("%x", libraryID.Bytes)
|
||||||
|
log.Printf("Triggering scheduled scan for library %s", libraryIDStr)
|
||||||
|
|
||||||
folders, err := s.db.GetLibraryFolders(ctx, libraryID)
|
folders, err := s.db.GetLibraryFolders(ctx, libraryID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error getting folders for library %s: %v", libraryID, err)
|
log.Printf("Error getting folders for library %s: %v", libraryIDStr, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(folders) == 0 {
|
if len(folders) == 0 {
|
||||||
log.Printf("No folders configured for library %s, skipping scan", libraryID)
|
log.Printf("No folders configured for library %s, skipping scan", libraryIDStr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +197,8 @@ func (s *Scheduler) triggerScheduledScan(ctx context.Context, libraryID pgtype.U
|
|||||||
if err := s.worker.EnqueueJob(job); err != nil {
|
if err := s.worker.EnqueueJob(job); err != nil {
|
||||||
log.Printf("Error enqueuing scan job: %v", err)
|
log.Printf("Error enqueuing scan job: %v", err)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Enqueued scan job %s for library %s", job.ID, libraryID)
|
libraryIDStr := fmt.Sprintf("%x", libraryID.Bytes)
|
||||||
|
log.Printf("Enqueued scan job %s for library %s", job.ID, libraryIDStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user