diff --git a/README.md b/README.md index 16f6cba66..dc62bf74b 100644 --- a/README.md +++ b/README.md @@ -470,7 +470,9 @@ params.TargetProps = targetProps TargetPathInArchive := "archive/path/" // Size limit for files to be uploaded. SizeLimit= &fspatterns.SizeThreshold{SizeInBytes: 10000, Condition: fspatterns.LessThan} -totalUploaded, totalFailed, err := rtManager.UploadFiles(params) +// Set to true to fail the upload operation if any of the files fail to upload +failFast := false +totalUploaded, totalFailed, err := rtManager.UploadFiles(failFast, params) ``` #### Downloading Files from Artifactory @@ -547,8 +549,10 @@ calling `Close()` on the OperationSummary struct. params := services.NewUploadParams() params.Pattern = "repo/*/*.zip" params.Target = "repo/path/" +// Set to true to fail the upload operation if any of the files fail to upload +failFast := false -summary, err := rtManager.UploadFilesWithSummary(params) +summary, err := rtManager.UploadFilesWithSummary(failFast, params) defer summary.Close() reader, totalDownloaded, totalExpected, err := rtManager.DownloadFilesWithResultReader(params) diff --git a/artifactory/emptymanager.go b/artifactory/emptymanager.go index 2060c10f2..eac95735d 100644 --- a/artifactory/emptymanager.go +++ b/artifactory/emptymanager.go @@ -56,9 +56,8 @@ type ArtifactoryServicesManager interface { SetProps(params services.PropsParams) (int, error) DeleteProps(params services.PropsParams) (int, error) GetItemProps(relativePath string) (*utils.ItemProperties, error) - UploadFilesWithSummary(params ...services.UploadParams) (operationSummary *utils.OperationSummary, err error) - UploadFiles(params ...services.UploadParams) (totalUploaded, totalFailed int, err error) - UploadFilesWithFailFast(params ...services.UploadParams) (totalUploaded, totalFailed int, err error) + UploadFiles(failFast bool, params ...services.UploadParams) (totalUploaded, totalFailed int, err error) + UploadFilesWithSummary(failFast bool, params ...services.UploadParams) (operationSummary *utils.OperationSummary, err error) Copy(params ...services.MoveCopyParams) (successCount, failedCount int, err error) Move(params ...services.MoveCopyParams) (successCount, failedCount int, err error) PublishGoProject(params _go.GoParams) (*utils.OperationSummary, error) @@ -263,15 +262,11 @@ func (esm *EmptyArtifactoryServicesManager) GetItemProps(string) (*utils.ItemPro panic("Failed: Method is not implemented") } -func (esm *EmptyArtifactoryServicesManager) UploadFiles(...services.UploadParams) (int, int, error) { +func (esm *EmptyArtifactoryServicesManager) UploadFiles(_ bool, _ ...services.UploadParams) (int, int, error) { panic("Failed: Method is not implemented") } -func (esm *EmptyArtifactoryServicesManager) UploadFilesWithFailFast(...services.UploadParams) (int, int, error) { - panic("Failed: Method is not implemented") -} - -func (esm *EmptyArtifactoryServicesManager) UploadFilesWithSummary(...services.UploadParams) (*utils.OperationSummary, error) { +func (esm *EmptyArtifactoryServicesManager) UploadFilesWithSummary(_ bool, _ ...services.UploadParams) (*utils.OperationSummary, error) { panic("Failed: Method is not implemented") } diff --git a/artifactory/manager.go b/artifactory/manager.go index 10a785bfe..ff48a5bf4 100644 --- a/artifactory/manager.go +++ b/artifactory/manager.go @@ -313,27 +313,20 @@ func (sm *ArtifactoryServicesManagerImp) initUploadService() *services.UploadSer return uploadService } -func (sm *ArtifactoryServicesManagerImp) UploadFiles(params ...services.UploadParams) (totalUploaded, totalFailed int, err error) { - return sm.uploadFiles(sm.initUploadService(), params...) -} - -func (sm *ArtifactoryServicesManagerImp) UploadFilesWithFailFast(params ...services.UploadParams) (totalUploaded, totalFailed int, err error) { +func (sm *ArtifactoryServicesManagerImp) UploadFiles(failFast bool, params ...services.UploadParams) (totalUploaded, totalFailed int, err error) { uploadService := sm.initUploadService() - uploadService.SetFailFast(true) - return sm.uploadFiles(uploadService, params...) -} - -func (sm *ArtifactoryServicesManagerImp) uploadFiles(uploadService *services.UploadService, uploadParams ...services.UploadParams) (totalUploaded, totalFailed int, err error) { - summary, err := uploadService.UploadFiles(uploadParams...) + uploadService.SetFailFast(failFast) + summary, err := uploadService.UploadFiles(params...) if summary == nil { return 0, 0, err } return summary.TotalSucceeded, summary.TotalFailed, err } -func (sm *ArtifactoryServicesManagerImp) UploadFilesWithSummary(params ...services.UploadParams) (operationSummary *utils.OperationSummary, err error) { +func (sm *ArtifactoryServicesManagerImp) UploadFilesWithSummary(failFast bool, params ...services.UploadParams) (operationSummary *utils.OperationSummary, err error) { uploadService := sm.initUploadService() uploadService.SetSaveSummary(true) + uploadService.SetFailFast(failFast) return uploadService.UploadFiles(params...) }