MCPcopy
hub / github.com/git-lfs/git-lfs / upload

Method upload

tq/ssh.go:340–379  ·  view source on GitHub ↗

upload starts an upload.

(t *Transfer, workerNum int, cb ProgressCallback)

Source from the content-addressed store, hash-verified

338
339// upload starts an upload.
340func (a *SSHAdapter) upload(t *Transfer, workerNum int, cb ProgressCallback) error {
341 rel, err := t.Rel("upload")
342 if err != nil {
343 return err
344 }
345 if rel == nil {
346 return errors.New(tr.Tr.Get("No upload action for object: %s", t.Oid))
347 }
348
349 f, err := os.OpenFile(t.Path, os.O_RDONLY, 0644)
350 if err != nil {
351 return errors.Wrap(err, tr.Tr.Get("SSH upload"))
352 }
353 defer f.Close()
354
355 status, _, lines, err := a.doUpload(t, workerNum, f, cb)
356 if err != nil {
357 return err
358 }
359 if status < 200 || status > 299 {
360 // A status code of 403 likely means that an authentication token for the
361 // upload has expired. This can be safely retried.
362 if status == 403 {
363 err = errors.New(tr.Tr.Get("Received status %d", status))
364 return errors.NewRetriableError(err)
365 }
366
367 if status == 429 {
368 return errors.NewRetriableError(errors.New(tr.Tr.Get("got status %d when uploading OID %s", status, t.Oid)))
369 }
370
371 if len(lines) > 0 {
372 return errors.New(tr.Tr.Get("got status %d when uploading OID %s: %s", status, t.Oid, lines[0]))
373 }
374 return errors.New(tr.Tr.Get("got status %d when uploading OID %s", status, t.Oid))
375
376 }
377
378 return a.verifyUpload(t, workerNum)
379}
380
381func (a *SSHAdapter) argumentsForTransfer(t *Transfer, action string) []string {
382 args := make([]string, 0, 3)

Callers 1

DoTransferMethod · 0.95

Calls 8

doUploadMethod · 0.95
verifyUploadMethod · 0.95
NewFunction · 0.92
WrapFunction · 0.92
NewRetriableErrorFunction · 0.92
RelMethod · 0.80
GetMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected