Skip to content

Commit 4b847ea

Browse files
author
elchananarb
committed
Extract to a "Wait()" method
1 parent 1f087c2 commit 4b847ea

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

internal/commands/scan.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,10 +2634,7 @@ func cleanUpTempZip(zipFilePath string) {
26342634
),
26352635
)
26362636
tries--
2637-
// Calculate exponential backoff delay
2638-
waitDuration := time.Duration(cleanupRetryWaitSeconds * (1 << (attempt - 1))) // 2^(attempt-1)
2639-
logger.PrintIfVerbose(fmt.Sprintf("Waiting %d seconds before retrying...", waitDuration))
2640-
time.Sleep(waitDuration * time.Second)
2637+
Wait(attempt)
26412638
} else {
26422639
logger.PrintIfVerbose("Removed temporary zip")
26432640
break
@@ -2651,6 +2648,13 @@ func cleanUpTempZip(zipFilePath string) {
26512648
}
26522649
}
26532650

2651+
func Wait(attempt int) {
2652+
// Calculate exponential backoff delay
2653+
waitDuration := time.Duration(cleanupRetryWaitSeconds * (1 << (attempt - 1))) // 2^(attempt-1)
2654+
logger.PrintIfVerbose(fmt.Sprintf("Waiting %d seconds before retrying...", waitDuration))
2655+
time.Sleep(waitDuration * time.Second)
2656+
}
2657+
26542658
func deprecatedFlagValue(cmd *cobra.Command, deprecatedFlagKey, inUseFlagKey string) string {
26552659
flagValue, _ := cmd.Flags().GetString(inUseFlagKey)
26562660
if flagValue == "" {

0 commit comments

Comments
 (0)