Skip to content

Commit e81bbd9

Browse files
committed
removed unnecessary flags from ddl cmd, renamed cmd
1 parent 38a86e0 commit e81bbd9

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed

artifactory/cli/cli.go

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ func GetCommands() []components.Command {
104104
Category: filesCategory,
105105
},
106106
{
107-
Name: "native-download",
108-
Flags: flagkit.GetCommandFlags(flagkit.NativeDownload),
109-
Aliases: []string{"ndl"},
107+
Name: "direct-download",
108+
Flags: flagkit.GetCommandFlags(flagkit.DirectDownload),
109+
Aliases: []string{"ddl"},
110110
Description: directdownload.GetDescription(),
111111
Arguments: directdownload.GetArguments(),
112112
Action: directDownloadCmd,
@@ -738,28 +738,7 @@ func createDirectDownloadSpec(c *components.Context) (*spec.SpecFiles, error) {
738738
BuildSpec(), nil
739739
}
740740

741-
func validateDirectDownloadFlags(c *components.Context) error {
742-
incompatibleFlags := []string{
743-
"sort-by", "sort-order", "limit", "offset",
744-
"props", "exclude-props", "archive-entries",
745-
"bundle", "gpg-key", "include-dirs",
746-
"bypass-archive-inspection", "validate-symlinks",
747-
}
748-
749-
for _, flag := range incompatibleFlags {
750-
if c.IsFlagSet(flag) {
751-
return errorutils.CheckErrorf("The --%s flag is not supported with native download", flag)
752-
}
753-
}
754-
755-
return nil
756-
}
757-
758741
func directDownloadCmd(c *components.Context) error {
759-
if err := validateDirectDownloadFlags(c); err != nil {
760-
return err
761-
}
762-
763742
downloadSpec, err := prepareDirectDownloadCommand(c)
764743
if err != nil {
765744
return err

artifactory/commands/generic/directdownload.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ func (ddc *DirectDownloadCommand) Run() error {
4646
}
4747

4848
func (ddc *DirectDownloadCommand) directDownload() error {
49-
servicesManager, err := utils.CreateServiceManager(ddc.serverDetails, -1, 0, ddc.DryRun())
49+
// Use the threads configuration from the download command
50+
threads := 3 // Default threads
51+
if ddc.configuration != nil && ddc.configuration.Threads > 0 {
52+
threads = ddc.configuration.Threads
53+
}
54+
55+
servicesManager, err := utils.CreateServiceManager(ddc.serverDetails, threads, 0, ddc.DryRun())
5056
if err != nil {
5157
return err
5258
}
@@ -77,16 +83,23 @@ func (ddc *DirectDownloadCommand) directDownload() error {
7783
downloadParams.SetSyncDeletesPath(ddc.SyncDeletesPath())
7884
downloadParams.SetQuiet(ddc.quiet)
7985

86+
// Set split download parameters from configuration
87+
if ddc.configuration != nil {
88+
downloadParams.MinSplitSizeMB = ddc.configuration.MinSplitSize / 1024 // Convert KB to MB
89+
downloadParams.SplitCount = ddc.configuration.SplitCount
90+
}
91+
8092
downloadParamsArray = append(downloadParamsArray, *downloadParams)
8193
}
8294

8395
var summary *serviceutils.OperationSummary
8496
// We need the detailed summary when either showing detailed output or performing sync-deletes
97+
// (sync-deletes needs the file list to know what to keep)
8598
if ddc.DetailedSummary() || ddc.SyncDeletesPath() != "" {
86-
summary, err = servicesManager.DownloadFilesWithoutAQLWithSummary(downloadParamsArray...)
99+
summary, err = servicesManager.DirectDownloadFilesWithSummary(downloadParamsArray...)
87100
} else {
88101
var totalDownloaded, totalFailed int
89-
totalDownloaded, totalFailed, err = servicesManager.DownloadFilesWithoutAQL(downloadParamsArray...)
102+
totalDownloaded, totalFailed, err = servicesManager.DirectDownloadFiles(downloadParamsArray...)
90103
summary = &serviceutils.OperationSummary{
91104
TotalSucceeded: totalDownloaded,
92105
TotalFailed: totalFailed,
@@ -114,6 +127,8 @@ func (ddc *DirectDownloadCommand) directDownload() error {
114127
}
115128

116129
// handleSyncDeletes removes local files that weren't part of the current download operation.
130+
// It creates a temporary directory structure mirroring downloaded files, then walks the target
131+
// directory to identify and delete files that don't exist in the download set.
117132
func (ddc *DirectDownloadCommand) handleSyncDeletes(reader *content.ContentReader) error {
118133
reader.Reset()
119134

cliutils/flagkit/flags.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const (
2929
// Artifactory's Commands Keys
3030
Upload = "upload"
3131
Download = "download"
32-
NativeDownload = "native-download"
32+
DirectDownload = "direct-download"
3333
Move = "move"
3434
Copy = "copy"
3535
Delete = "delete"
@@ -553,13 +553,13 @@ var commandFlags = map[string][]string{
553553
downloadProps, downloadExcludeProps, failNoOp, threads, archiveEntries, downloadSyncDeletes, syncDeletesQuiet, InsecureTls, detailedSummary, Project,
554554
skipChecksum,
555555
},
556-
NativeDownload: {
556+
DirectDownload: {
557557
url, user, password, accessToken, sshPassphrase, sshKeyPath, serverId, ClientCertPath,
558558
ClientCertKeyPath, specFlag, specVars, BuildName, BuildNumber, module, exclusions,
559559
downloadRecursive, downloadFlat, build, includeDeps, excludeArtifacts, downloadMinSplit, downloadSplitCount,
560560
retries, retryWaitTime, dryRun, downloadExplode, threads, downloadSyncDeletes, syncDeletesQuiet, skipChecksum, failNoOp, detailedSummary, Project,
561-
sortBy, sortOrder, limit, offset, downloadProps, downloadExcludeProps, archiveEntries,
562-
bundle, publicGpgKey, includeDirs, bypassArchiveInspection, validateSymlinks,
561+
downloadProps, downloadExcludeProps, archiveEntries, bundle, publicGpgKey, includeDirs, bypassArchiveInspection, validateSymlinks,
562+
InsecureTls,
563563
},
564564
Move: {
565565
url, user, password, accessToken, sshPassphrase, sshKeyPath, serverId, ClientCertPath,

0 commit comments

Comments
 (0)