diff --git a/artifactory/commands/transferfiles/delayedartifactshandler.go b/artifactory/commands/transferfiles/delayedartifactshandler.go index 693babc20..b44aeb2c9 100644 --- a/artifactory/commands/transferfiles/delayedartifactshandler.go +++ b/artifactory/commands/transferfiles/delayedartifactshandler.go @@ -120,7 +120,7 @@ func consumeDelayFilesIfNoErrors(phase phaseBase, addedDelayFiles []string) erro if len(addedDelayFiles) > 0 && phase.progressBar != nil { phaseTaskProgressBar := phase.progressBar.phases[phase.phaseId].GetTasksProgressBar() oldTotal := phaseTaskProgressBar.GetTotal() - delayCount, err := countDelayFilesContent(addedDelayFiles) + delayCount, _, err := countDelayFilesContent(addedDelayFiles) if err != nil { return err } @@ -129,16 +129,20 @@ func consumeDelayFilesIfNoErrors(phase phaseBase, addedDelayFiles []string) erro return nil } -func countDelayFilesContent(filePaths []string) (int, error) { +func countDelayFilesContent(filePaths []string) (int, int64, error) { count := 0 + var storage int64 = 0 for _, file := range filePaths { delayFile, err := readDelayFile(file) if err != nil { - return 0, err + return 0, storage, err } count += len(delayFile.DelayedArtifacts) + for _, delay := range delayFile.DelayedArtifacts { + storage += delay.Size + } } - return count, nil + return count, storage, nil } func handleDelayedArtifactsFiles(filesToConsume []string, base phaseBase, delayUploadComparisonFunctions []shouldDelayUpload) error { diff --git a/artifactory/commands/transferfiles/delayedartifactshandler_test.go b/artifactory/commands/transferfiles/delayedartifactshandler_test.go index cd576f9e3..ebff3bfab 100644 --- a/artifactory/commands/transferfiles/delayedartifactshandler_test.go +++ b/artifactory/commands/transferfiles/delayedartifactshandler_test.go @@ -2,17 +2,18 @@ package transferfiles import ( "fmt" - "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferfiles/api" - "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferfiles/state" - "github.com/jfrog/jfrog-cli-core/v2/utils/tests" - "github.com/jfrog/jfrog-client-go/utils/io/fileutils" - "github.com/stretchr/testify/assert" "math" "os" "path/filepath" "sync" "testing" "time" + + "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferfiles/api" + "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferfiles/state" + "github.com/jfrog/jfrog-cli-core/v2/utils/tests" + "github.com/jfrog/jfrog-client-go/utils/io/fileutils" + "github.com/stretchr/testify/assert" ) var delayTestRepoKey = "delay-local-repo" @@ -52,7 +53,7 @@ func TestDelayedArtifactsMng(t *testing.T) { go func() { defer writeWaitGroup.Done() for i := 0; i < artifactsNumber; i++ { - artifactsChannelMng.channel <- api.FileRepresentation{Repo: testRepoKey, Path: "path", Name: fmt.Sprintf("name%d", i)} + artifactsChannelMng.channel <- api.FileRepresentation{Repo: testRepoKey, Path: "path", Name: fmt.Sprintf("name%d", i), Size: int64(i)} } }() @@ -71,8 +72,9 @@ func TestDelayedArtifactsMng(t *testing.T) { expectedNumberOfFiles := int(math.Ceil(float64(artifactsNumber) / float64(maxDelayedArtifactsInFile))) validateDelayedArtifactsFiles(t, delayFiles, expectedNumberOfFiles, artifactsNumber) - delayCount, err := countDelayFilesContent(delayFiles) + delayCount, storage, err := countDelayFilesContent(delayFiles) assert.NoError(t, err) + assert.Equal(t, int64(1225), storage) assert.Equal(t, delayCount, artifactsNumber) } diff --git a/artifactory/commands/transferfiles/fileserror.go b/artifactory/commands/transferfiles/fileserror.go index 7cf746c04..0a74b5e75 100644 --- a/artifactory/commands/transferfiles/fileserror.go +++ b/artifactory/commands/transferfiles/fileserror.go @@ -3,13 +3,14 @@ package transferfiles import ( "errors" "fmt" + "os" + "strings" + "time" + "github.com/jfrog/gofrog/parallel" "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferfiles/api" "github.com/jfrog/jfrog-client-go/utils/errorutils" "github.com/jfrog/jfrog-client-go/utils/log" - "os" - "strings" - "time" ) type errorFileHandlerFunc func() parallel.TaskFunc @@ -150,6 +151,19 @@ func (e *errorsRetryPhase) initProgressBar() error { filesCount += len(failedFiles.Errors) } // The progress bar will also be responsible to display the number of delayed items for this repository. + // Those delayed artifacts will be handled at the end of this phase in case they exist. + delayFiles, err := getDelayFiles([]string{e.repoKey}) + if err != nil { + return err + } + delayCount, delayStorage, err := countDelayFilesContent(delayFiles) + if err != nil { + return err + } + err = e.stateManager.SetTotalSizeAndFilesPhase3(int64(filesCount)+int64(delayCount), storage+delayStorage) + if err != nil { + return err + } e.progressBar.AddPhase3() return nil } diff --git a/artifactory/commands/transferfiles/status.go b/artifactory/commands/transferfiles/status.go index 0ffd1d6be..bd5da9b61 100644 --- a/artifactory/commands/transferfiles/status.go +++ b/artifactory/commands/transferfiles/status.go @@ -102,7 +102,7 @@ func setRepositoryStatus(stateManager *state.TransferStateManager, output *strin if stateManager.CurrentRepoPhase == api.Phase1 { addString(output, "🔢", "Phase", "Transferring all files in the repository (1/3)", 3) } else { - addString(output, "🔢", "Phase", "Retrying transfer failures (3/3)", 3) + addString(output, "🔢", "Phase", "Retrying transfer failures and deploy delayed files (3/3)", 3) } addString(output, "🗄 ", "Storage", sizeToString(currentRepo.Phase1Info.TransferredSizeBytes)+" / "+sizeToString(currentRepo.Phase1Info.TotalSizeBytes)+calcPercentageInt64(currentRepo.Phase1Info.TransferredSizeBytes, currentRepo.Phase1Info.TotalSizeBytes), 3) addString(output, "📄", "Files", fmt.Sprintf("%d / %d", currentRepo.Phase1Info.TransferredUnits, currentRepo.Phase1Info.TotalUnits)+calcPercentageInt64(currentRepo.Phase1Info.TransferredUnits, currentRepo.Phase1Info.TotalUnits), 3) diff --git a/artifactory/commands/transferfiles/status_test.go b/artifactory/commands/transferfiles/status_test.go index 37be3b113..adef939d4 100644 --- a/artifactory/commands/transferfiles/status_test.go +++ b/artifactory/commands/transferfiles/status_test.go @@ -138,7 +138,7 @@ func TestShowBuildInfoRepo(t *testing.T) { // Check repository status assert.Contains(t, results, "Current Repository Status") assert.Contains(t, results, "Name: repo1") - assert.Contains(t, results, "Phase: Retrying transfer failures (3/3)") + assert.Contains(t, results, "Phase: Retrying transfer failures and deploy delayed files (3/3)") assert.Contains(t, results, "Delayed files: 20 (Files to be transferred last, after all other files)") assert.Contains(t, results, "Storage: 4.9 KiB / 9.8 KiB (50.0%)") assert.Contains(t, results, "Files: 500 / 10000 (5.0%)") diff --git a/utils/progressbar/transferprogressbarmanager.go b/utils/progressbar/transferprogressbarmanager.go index 840ccd02d..48a02f5a1 100644 --- a/utils/progressbar/transferprogressbarmanager.go +++ b/utils/progressbar/transferprogressbarmanager.go @@ -15,7 +15,7 @@ import ( const ( phase1HeadLine = "Phase 1: Transferring all files in the repository" phase2HeadLine = "Phase 2: Transferring newly created and modified files" - phase3HeadLine = "Phase 3: Retrying transfer failures" + phase3HeadLine = "Phase 3: Retrying transfer failures and deploy delayed files" DelayedFilesContentNote = "Files to be transferred last, after all other files" RetryFailureContentNote = "In Phase 3 and in subsequent executions, we'll retry transferring the failed files" )