From 5f5d083c78a288eb16ddf8169cd838f6846d774d Mon Sep 17 00:00:00 2001 From: Omer Zidkoni <50792403+omerzi@users.noreply.github.com> Date: Sun, 8 Sep 2024 17:28:34 +0300 Subject: [PATCH] SA --- artifactory/commands/transferfiles/state/timeestimation.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/artifactory/commands/transferfiles/state/timeestimation.go b/artifactory/commands/transferfiles/state/timeestimation.go index 7ad3d7d6d..9e17c01d6 100644 --- a/artifactory/commands/transferfiles/state/timeestimation.go +++ b/artifactory/commands/transferfiles/state/timeestimation.go @@ -66,13 +66,13 @@ func (tem *TimeEstimationManager) addDataChunkStatus(chunkStatus api.ChunkStatus // If no files were uploaded regularly (with no errors and not checksum-deployed), don't use this chunk for the time estimation calculation. if chunkSizeBytes == 0 { - return + return nil } workingThreads, err := tem.stateManager.GetWorkingThreads() if err != nil { log.Error("Couldn't calculate time estimation:", err.Error()) - return + return err } speed := calculateChunkSpeed(workingThreads, chunkSizeBytes, durationMillis) tem.LastSpeeds = append(tem.LastSpeeds, speed) @@ -85,10 +85,11 @@ func (tem *TimeEstimationManager) addDataChunkStatus(chunkStatus api.ChunkStatus } if len(tem.LastSpeeds) == 0 { tem.SpeedsAverage = 0 - return + return err } // Calculate speed in bytes/ms tem.SpeedsAverage = tem.LastSpeedsSum / float64(len(tem.LastSpeeds)) + return nil } func calculateChunkSpeed(workingThreads int, chunkSizeSum, chunkDuration int64) float64 {