MCPcopy
hub / github.com/NVIDIA/aistore / startDownloadHandler

Function startDownloadHandler

cmd/cli/commands/job_start.go:182–353  ·  view source on GitHub ↗
(c *cli.Context)

Source from the content-addressed store, hash-verified

180}
181
182func startDownloadHandler(c *cli.Context) error {
183 var (
184 description = parseStrFlag(c, descJobFlag)
185 timeout = parseStrFlag(c, timeoutFlag)
186 objectsListPath = parseStrFlag(c, objectsListFlag)
187 progressInterval = parseStrFlag(c, progressIntervalFlag)
188 id string
189 )
190
191 if c.NArg() == 0 {
192 return missingArgumentsError(c, "source", "destination")
193 }
194 if c.NArg() == 1 {
195 return missingArgumentsError(c, "destination")
196 }
197 if c.NArg() > 2 {
198 const q = "For range download, enclose source in quotation marks, e.g.: \"gs://imagenet/train-{00..99}.tgz\""
199 s := fmt.Sprintf("too many arguments - expected 2, got %d.\n%s", len(c.Args()), q)
200 return &errUsage{
201 context: c,
202 message: s,
203 helpData: c.Command,
204 helpTemplate: cli.CommandHelpTemplate,
205 }
206 }
207
208 src, dst := c.Args().Get(0), c.Args().Get(1)
209 source, err := parseSource(src)
210 if err != nil {
211 return err
212 }
213 bck, pathSuffix, err := parseDest(c, dst)
214 if err != nil {
215 return err
216 }
217
218 limitBPH, err := parseByteFlagToInt(c, limitBytesPerHourFlag)
219 if err != nil {
220 return err
221 }
222
223 if _, err := time.ParseDuration(progressInterval); err != nil {
224 return err
225 }
226
227 basePayload := downloader.DlBase{
228 Bck: bck,
229 Timeout: timeout,
230 Description: description,
231 ProgressInterval: progressInterval,
232 Limits: downloader.DlLimits{
233 Connections: parseIntFlag(c, limitConnectionsFlag),
234 BytesPerHour: int(limitBPH),
235 },
236 }
237
238 if basePayload.Bck.Props, err = api.HeadBucket(defaultAPIParams, basePayload.Bck); err != nil {
239 if !cmn.IsStatusNotFound(err) {

Callers

nothing calls this directly

Calls 15

HeadBucketFunction · 0.92
IsStatusNotFoundFunction · 0.92
DownloadWithParamFunction · 0.92
AssertFunction · 0.92
parseStrFlagFunction · 0.85
parseSourceFunction · 0.85
parseDestFunction · 0.85
parseByteFlagToIntFunction · 0.85
parseIntFlagFunction · 0.85
getRandTargetConfigFunction · 0.85
flagIsSetFunction · 0.85
pbDownloadFunction · 0.85

Tested by

no test coverage detected