Apply mechanical lint fixes for golangci-lint v2.12.2 rollout
Auto-remediate style-only findings (wsl_v5, nlreturn, noinlineerr, modernize, intrange, perfsprint, usetesting, unconvert, errorlint, gocritic, testifylint) and rename printf-style helpers to f-suffixed names (goprintffuncname): ui.Writer message methods, cli.ReportErrorf, database.Fatalf, vaultik stdoutf.
This commit is contained in:
@@ -153,6 +153,7 @@ func (pr *ProgressReporter) printSummaryStatus() {
|
||||
if uploadInfo, ok := pr.stats.CurrentUpload.Load().(*UploadInfo); ok && uploadInfo != nil {
|
||||
// Show upload progress instead
|
||||
pr.printUploadProgress(uploadInfo)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -175,16 +176,18 @@ func (pr *ProgressReporter) printSummaryStatus() {
|
||||
|
||||
// Calculate ETA if we have total size and are processing
|
||||
etaStr := ""
|
||||
|
||||
if totalSize > 0 && bytesProcessed > 0 {
|
||||
processStart, ok := pr.stats.ProcessStartTime.Load().(time.Time)
|
||||
if ok && !processStart.IsZero() {
|
||||
processElapsed := time.Since(processStart)
|
||||
|
||||
rate := float64(bytesProcessed) / processElapsed.Seconds()
|
||||
if rate > 0 {
|
||||
remainingBytes := totalSize - bytesProcessed
|
||||
remainingSeconds := float64(remainingBytes) / rate
|
||||
eta := time.Duration(remainingSeconds * float64(time.Second))
|
||||
etaStr = fmt.Sprintf(" | ETA: %s", formatDuration(eta))
|
||||
etaStr = " | ETA: " + formatDuration(eta)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,7 +209,7 @@ func (pr *ProgressReporter) printSummaryStatus() {
|
||||
)
|
||||
|
||||
if currentFile != "" {
|
||||
status += fmt.Sprintf(" | Current: %s", truncatePath(currentFile, 40))
|
||||
status += " | Current: " + truncatePath(currentFile, 40)
|
||||
}
|
||||
|
||||
log.Info(status)
|
||||
@@ -242,6 +245,7 @@ func (pr *ProgressReporter) printDetailedStatus() {
|
||||
processStart, ok := pr.stats.ProcessStartTime.Load().(time.Time)
|
||||
if ok && !processStart.IsZero() {
|
||||
processElapsed := time.Since(processStart)
|
||||
|
||||
processRate := float64(bytesProcessed) / processElapsed.Seconds()
|
||||
if processRate > 0 {
|
||||
remainingBytes := totalSize - bytesProcessed
|
||||
@@ -276,9 +280,11 @@ func (pr *ProgressReporter) printDetailedStatus() {
|
||||
log.Info("Total uploaded to remote",
|
||||
"uploaded", humanize.Bytes(uint64(bytesUploaded)),
|
||||
"compression_ratio", formatRatio(bytesUploaded, bytesScanned))
|
||||
|
||||
if currentFile != "" {
|
||||
log.Info("Current file", "path", currentFile)
|
||||
}
|
||||
|
||||
log.Notice("=============================")
|
||||
}
|
||||
|
||||
@@ -288,12 +294,15 @@ func formatDuration(d time.Duration) string {
|
||||
if d < 0 {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
if d < time.Minute {
|
||||
return fmt.Sprintf("%ds", int(d.Seconds()))
|
||||
}
|
||||
|
||||
if d < time.Hour {
|
||||
return fmt.Sprintf("%dm%ds", int(d.Minutes()), int(d.Seconds())%60)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%dh%dm", int(d.Hours()), int(d.Minutes())%60)
|
||||
}
|
||||
|
||||
@@ -301,6 +310,7 @@ func formatPercent(numerator, denominator int64) string {
|
||||
if denominator == 0 {
|
||||
return "0.0%"
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%.1f%%", float64(numerator)/float64(denominator)*100)
|
||||
}
|
||||
|
||||
@@ -308,7 +318,9 @@ func formatRatio(compressed, uncompressed int64) string {
|
||||
if uncompressed == 0 {
|
||||
return "1.00"
|
||||
}
|
||||
|
||||
ratio := float64(compressed) / float64(uncompressed)
|
||||
|
||||
return fmt.Sprintf("%.2f", ratio)
|
||||
}
|
||||
|
||||
@@ -353,6 +365,7 @@ func (pr *ProgressReporter) ReportUploadComplete(blobHash string, size int64, du
|
||||
if duration < time.Millisecond {
|
||||
duration = time.Millisecond
|
||||
}
|
||||
|
||||
bytesPerSec := float64(size) / duration.Seconds()
|
||||
bitsPerSec := bytesPerSec * 8
|
||||
|
||||
@@ -398,6 +411,7 @@ func (pr *ProgressReporter) ReportUploadProgress(blobHash string, bytesUploaded,
|
||||
|
||||
// Calculate ETA based on current speed
|
||||
etaStr := "unknown"
|
||||
|
||||
if instantSpeed > 0 && bytesUploaded < totalSize {
|
||||
remainingBytes := totalSize - bytesUploaded
|
||||
remainingSeconds := float64(remainingBytes) / instantSpeed
|
||||
|
||||
Reference in New Issue
Block a user