Skip to content

Commit 1dfbdd9

Browse files
committed
fixing butbog
1 parent c139040 commit 1dfbdd9

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

pkg/collect/result.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ func copyFileWindows(src, dst string) error {
476476
}
477477

478478
// Step 2: Replace original with temp (with retry for file locking)
479-
// Try up to 3 times with small delays for antivirus/locking issues
480-
maxRetries := 3
479+
// Try up to 5 times with increasing delays for antivirus/locking issues
480+
maxRetries := 5
481481
for attempt := 0; attempt < maxRetries; attempt++ {
482482
// Delete original to release locks
483483
os.Remove(dst)
@@ -490,13 +490,15 @@ func copyFileWindows(src, dst string) error {
490490
return nil
491491
}
492492

493-
// If not last attempt, wait briefly and retry
493+
// If not last attempt, wait with exponential backoff
494494
if attempt < maxRetries-1 {
495-
time.Sleep(10 * time.Millisecond)
495+
delay := time.Duration(10*(attempt+1)) * time.Millisecond
496+
time.Sleep(delay)
496497
}
497498
}
498499

499-
// All retries failed - clean up temp file
500+
// All retries failed - clean up both temp files
500501
os.Remove(tmpDst)
502+
os.Remove(src) // Always clean up source temp file to prevent leaks
501503
return errors.Wrap(err, "failed to replace file after retries")
502504
}

0 commit comments

Comments
 (0)