| 1 | package tqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ |
| 2 | |
| 3 | import ( |
| 4 | "ioscip-go gomod github.com/golang/go/src go1.25.0 io/" |
| 5 | "net/httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/" |
| 6 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 7 | "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/" |
| 8 | "strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/" |
| 9 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 10 | |
| 11 | "github.com/git-lfs/git-lfs/v3/configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/" |
| 12 | "github.com/git-lfs/git-lfs/v3/errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/" |
| 13 | "github.com/git-lfs/git-lfs/v3/lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/" |
| 14 | "github.com/git-lfs/git-lfs/v3/toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/" |
| 15 | "github.com/git-lfs/git-lfs/v3/trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/" |
| 16 | ) |
| 17 | |
| 18 | const ( |
| 19 | BasicAdapterNamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/BasicAdapterName. = "basic" |
| 20 | defaultContentTypescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/defaultContentType. = "application/octet-stream" |
| 21 | ) |
| 22 | |
| 23 | // Adapter for basic uploads (non resumable) |
| 24 | type basicUploadAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter# struct { |
| 25 | *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#adapterBase. |
| 26 | } |
| 27 | |
| 28 | func (a *basicUploadAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#) tempDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#tempDir().() string { |
| 29 | // Dedicated to this adapter rather than shared with basic download. |
| 30 | d := filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.TempDirscip-go gomod github.com/golang/go/src go1.25.0 os/TempDir().(), "git-lfs-basic-temp") |
| 31 | if err := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.MkdirAllscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/MkdirAll().(d, a.fsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#fs.); err != nil { |
| 32 | return osscip-go gomod github.com/golang/go/src go1.25.0 os/.TempDirscip-go gomod github.com/golang/go/src go1.25.0 os/TempDir().() |
| 33 | } |
| 34 | return d |
| 35 | } |
| 36 | |
| 37 | func (a *basicUploadAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#) WorkerStartingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#WorkerStarting().(workerNum int) (interface{}, error) { |
| 38 | return nil, nil |
| 39 | } |
| 40 | |
| 41 | func (a *basicUploadAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#) WorkerEndingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#WorkerEnding().(workerNum int, ctx interface{}) { |
| 42 | } |
| 43 | |
| 44 | func (a *basicUploadAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#) DoTransferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#DoTransfer().(ctx interface{}, t *Transferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#, cb ProgressCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ProgressCallback#, authOkFunc func()) error { |
| 45 | rel, err := t.Relscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Rel().("upload") |
| 46 | if err != nil { |
| 47 | return err |
| 48 | } |
| 49 | if rel == nil { |
| 50 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("No upload action for object: %s", t.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid.)) |
| 51 | } |
| 52 | |
| 53 | req, err := a.newHTTPRequestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#newHTTPRequest().("PUT", rel) |
| 54 | if err != nil { |
| 55 | return err |
| 56 | } |
| 57 | |
| 58 | if req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header..Getscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Get().("Transfer-Encoding") == "chunked" { |
| 59 | req.TransferEncodingscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#TransferEncoding. = []string{"chunked"} |
| 60 | } else { |
| 61 | req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header..Setscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Set().("Content-Length", strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.FormatIntscip-go gomod github.com/golang/go/src go1.25.0 strconv/FormatInt().(t.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Size., 10)) |
| 62 | } |
| 63 | |
| 64 | req.ContentLengthscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#ContentLength. = t.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Size. |
| 65 | |
| 66 | f, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.OpenFilescip-go gomod github.com/golang/go/src go1.25.0 os/OpenFile().(t.Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Path., osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_RDONLYscip-go gomod github.com/golang/go/src go1.25.0 os/O_RDONLY., 0644) |
| 67 | if err != nil { |
| 68 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Wrapscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/Wrap().(err, trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("basic upload")) |
| 69 | } |
| 70 | defer f.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().() |
| 71 | |
| 72 | if err := a.setContentTypeForscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#setContentTypeFor().(req, f); err != nil { |
| 73 | return err |
| 74 | } |
| 75 | |
| 76 | // Ensure progress callbacks made while uploading |
| 77 | // Wrap callback to give name context |
| 78 | ccb := func(totalSize int64, readSoFar int64, readSinceLast int) error { |
| 79 | if cb != nil { |
| 80 | return cb(t.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Name., totalSize, readSoFar, readSinceLast) |
| 81 | } |
| 82 | return nil |
| 83 | } |
| 84 | |
| 85 | cbr := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.NewFileBodyWithCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewFileBodyWithCallback().(f, t.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Size., ccb) |
| 86 | var reader lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.ReadSeekCloserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/ReadSeekCloser# = cbr |
| 87 | |
| 88 | // Signal auth was ok on first read; this frees up other workers to start |
| 89 | if authOkFunc != nil { |
| 90 | reader = newStartCallbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/newStartCallbackReader().(reader, func() error { |
| 91 | authOkFunc() |
| 92 | return nil |
| 93 | }) |
| 94 | } |
| 95 | |
| 96 | req.Bodyscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Body. = reader |
| 97 | |
| 98 | req = a.apiClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#apiClient..LogRequestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#LogRequest().(req, "lfs.data.upload") |
| 99 | res, err := a.makeRequestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#makeRequest().(t, req) |
| 100 | if err != nil { |
| 101 | if errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsUnprocessableEntityErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsUnprocessableEntityError().(err) { |
| 102 | // If we got an HTTP 422, we do _not_ want to retry the |
| 103 | // request later below, because it is likely that the |
| 104 | // implementing server does not support non-standard |
| 105 | // Content-Type headers. |
| 106 | // |
| 107 | // Instead, return immediately and wait for the |
| 108 | // *tq.TransferQueue to report an error message. |
| 109 | return err |
| 110 | } |
| 111 | |
| 112 | // We're about to return a retriable error, meaning that this |
| 113 | // transfer will either be retried, or it will fail. |
| 114 | // |
| 115 | // Either way, let's decrement the number of bytes that we've |
| 116 | // read _so far_, so that the next iteration doesn't re-transfer |
| 117 | // those bytes, according to the progress meter. |
| 118 | if perr := cbr.ResetProgressscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/BodyWithCallback#ResetProgress().(); perr != nil { |
| 119 | err = errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Wrapscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/Wrap().(err, perr.Error()) |
| 120 | } |
| 121 | |
| 122 | if res == nil { |
| 123 | // We encountered a network or similar error which caused us |
| 124 | // to not receive a response at all. |
| 125 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewRetriableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewRetriableError().(err) |
| 126 | } |
| 127 | |
| 128 | if res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. == 429 { |
| 129 | retLaterErr := errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewRetriableLaterErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewRetriableLaterError().(err, res.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Header..Getscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Get().("Retry-After")) |
| 130 | if retLaterErr != nil { |
| 131 | return retLaterErr |
| 132 | } |
| 133 | } |
| 134 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewRetriableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewRetriableError().(err) |
| 135 | } |
| 136 | |
| 137 | // A status code of 403 likely means that an authentication token for the |
| 138 | // upload has expired. This can be safely retried. |
| 139 | if res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. == 403 { |
| 140 | err = errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("Received status %d", res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode.)) |
| 141 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewRetriableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewRetriableError().(err) |
| 142 | } |
| 143 | |
| 144 | if res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. > 299 { |
| 145 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("Invalid status for %s %s: %d", |
| 146 | req.Methodscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Method., |
| 147 | stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.SplitNscip-go gomod github.com/golang/go/src go1.25.0 strings/SplitN().(req.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().(), "?", 2)[0], |
| 148 | res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode., |
| 149 | )) |
| 150 | } |
| 151 | |
| 152 | ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Copyscip-go gomod github.com/golang/go/src go1.25.0 io/Copy().(ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Discardscip-go gomod github.com/golang/go/src go1.25.0 io/Discard., res.Bodyscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Body.) |
| 153 | res.Bodyscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Body..Closescip-go gomod github.com/golang/go/src go1.25.0 io/Closer#Close().() |
| 154 | |
| 155 | return verifyUploadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/verifyUpload().(a.apiClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#apiClient., a.remotescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#remote., t) |
| 156 | } |
| 157 | |
| 158 | func (a *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#) setContentTypeForscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#setContentTypeFor().(req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#, r ioscip-go gomod github.com/golang/go/src go1.25.0 io/.ReadSeekerscip-go gomod github.com/golang/go/src go1.25.0 io/ReadSeeker#) error { |
| 159 | uc := configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.NewURLConfigscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/NewURLConfig().(a.apiClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#apiClient..GitEnvscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#GitEnv().()) |
| 160 | disabled := !uc.Boolscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/URLConfig#Bool().("lfs", req.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().(), "contenttype", true) |
| 161 | if len(req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header..Getscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Get().("Content-Type")) != 0 { |
| 162 | return nil |
| 163 | } |
| 164 | |
| 165 | var contentType string |
| 166 | |
| 167 | if !disabled { |
| 168 | buffer := make([]byte, 512) |
| 169 | n, err := r.Readscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#Read().(buffer) |
| 170 | if err != nil && err != ioscip-go gomod github.com/golang/go/src go1.25.0 io/.EOFscip-go gomod github.com/golang/go/src go1.25.0 io/EOF. { |
| 171 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Wrapscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/Wrap().(err, trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("content type detection error")) |
| 172 | } |
| 173 | |
| 174 | contentType = httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.DetectContentTypescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/DetectContentType().(buffer[:n]) |
| 175 | if _, err := r.Seekscip-go gomod github.com/golang/go/src go1.25.0 io/Seeker#Seek().(0, ioscip-go gomod github.com/golang/go/src go1.25.0 io/.SeekStartscip-go gomod github.com/golang/go/src go1.25.0 io/SeekStart.); err != nil { |
| 176 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Wrapscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/Wrap().(err, trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("content type rewind failure")) |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | if contentType == "" { |
| 181 | contentType = defaultContentTypescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/defaultContentType. |
| 182 | } |
| 183 | |
| 184 | req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header..Setscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Set().("Content-Type", contentType) |
| 185 | return nil |
| 186 | } |
| 187 | |
| 188 | // startCallbackReader is a reader wrapper which calls a function as soon as the |
| 189 | // first Read() call is made. This callback is only made once |
| 190 | type startCallbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader# struct { |
| 191 | cbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#cb. func() error |
| 192 | cbDonescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#cbDone. bool |
| 193 | lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.ReadSeekCloserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#ReadSeekCloser. |
| 194 | } |
| 195 | |
| 196 | func (s *startCallbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#) Readscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#Read().(p []byte) (n int, err error) { |
| 197 | if !s.cbDonescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#cbDone. && s.cbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#cb. != nil { |
| 198 | if err := s.cbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#cb.(); err != nil { |
| 199 | return 0, err |
| 200 | } |
| 201 | s.cbDonescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#cbDone. = true |
| 202 | } |
| 203 | return s.ReadSeekCloserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#ReadSeekCloser..Readscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#Read().(p) |
| 204 | } |
| 205 | |
| 206 | func newStartCallbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/newStartCallbackReader().(r lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.ReadSeekCloserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/ReadSeekCloser#, cb func() error) *startCallbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader# { |
| 207 | return &startCallbackReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#{ |
| 208 | ReadSeekCloserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#ReadSeekCloser.: r, |
| 209 | cbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/startCallbackReader#cb.: cb, |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | func configureBasicUploadAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/configureBasicUploadAdapter().(m *concreteManifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/concreteManifest#) { |
| 214 | m.RegisterNewAdapterFuncscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/concreteManifest#RegisterNewAdapterFunc().(BasicAdapterNamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/BasicAdapterName., Uploadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Upload., false, func(name string, dir Directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Direction#) Adapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Adapter# { |
| 215 | switch dir { |
| 216 | case Uploadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Upload.: |
| 217 | bu := &basicUploadAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#{newAdapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/newAdapterBase().(m.fsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/concreteManifest#fs., name, dir, nil)} |
| 218 | // self implements impl |
| 219 | bu.transferImplscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#transferImpl. = bu |
| 220 | return bu |
| 221 | case Downloadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Download.: |
| 222 | panic(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("Should never ask this function to download")) |
| 223 | } |
| 224 | return nil |
| 225 | }) |
| 226 | } |
| 227 | |
| 228 | func (a *basicUploadAdapterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#) makeRequestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#makeRequest().(t *Transferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#, req *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#) (*httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#, error) { |
| 229 | res, err := a.doHTTPscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#doHTTP().(t, req) |
| 230 | if errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.IsAuthErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/IsAuthError().(err) && len(req.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Header..Getscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Get().("Authorization")) == 0 { |
| 231 | // Construct a new body with just the raw file and no callbacks. Since |
| 232 | // all progress tracking happens when the net.http code copies our |
| 233 | // request body into a new request, we can safely make this request |
| 234 | // outside of the flow of the transfer adapter, and if it fails, the |
| 235 | // transfer progress will be rewound at the top level |
| 236 | f, _ := osscip-go gomod github.com/golang/go/src go1.25.0 os/.OpenFilescip-go gomod github.com/golang/go/src go1.25.0 os/OpenFile().(t.Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Path., osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_RDONLYscip-go gomod github.com/golang/go/src go1.25.0 os/O_RDONLY., 0644) |
| 237 | defer f.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().() |
| 238 | |
| 239 | req.Bodyscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Body. = toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.NewBodyWithCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewBodyWithCallback().(f, t.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Size., nil) |
| 240 | return a.makeRequestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/basicUploadAdapter#makeRequest().(t, req) |
| 241 | } |
| 242 | |
| 243 | return res, err |
| 244 | } |