| 1 | package tqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ |
| 2 | |
| 3 | import ( |
| 4 | "net/httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/" |
| 5 | "regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/" |
| 6 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 7 | "syncscip-go gomod github.com/golang/go/src go1.25.0 sync/" |
| 8 | |
| 9 | "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`/" |
| 10 | "github.com/git-lfs/git-lfs/v3/fsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/fs`/" |
| 11 | "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`/" |
| 12 | "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`/" |
| 13 | "github.com/rubyist/tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/" |
| 14 | ) |
| 15 | |
| 16 | // adapterBase implements the common functionality for core adapters which |
| 17 | // process transfers with N workers handling an oid each, and which wait for |
| 18 | // authentication to succeed on one worker before proceeding |
| 19 | type adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase# struct { |
| 20 | fsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#fs. *fsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/fs`/.Filesystemscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/fs`/Filesystem# |
| 21 | namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#name. string |
| 22 | directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#direction. Directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Direction# |
| 23 | transferImplscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#transferImpl. transferImplementationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/transferImplementation# |
| 24 | apiClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#apiClient. *lfsapiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/.Clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client# |
| 25 | remotescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#remote. string |
| 26 | jobChanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#jobChan. chan *jobscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job# |
| 27 | debuggingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#debugging. bool |
| 28 | cbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#cb. ProgressCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ProgressCallback# |
| 29 | // WaitGroup to sync the completion of all workers |
| 30 | workerWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#workerWait. syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.WaitGroupscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup# |
| 31 | // WaitGroup to sync the completion of all in-flight jobs |
| 32 | jobWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#jobWait. *syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.WaitGroupscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup# |
| 33 | // WaitGroup to serialise the first transfer response to perform login if needed |
| 34 | authWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#authWait. syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.WaitGroupscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup# |
| 35 | } |
| 36 | |
| 37 | // transferImplementation must be implemented to provide the actual upload/download |
| 38 | // implementation for all core transfer approaches that use adapterBase for |
| 39 | // convenience. This function will be called on multiple goroutines so it |
| 40 | // must be either stateless or thread safe. However it will never be called |
| 41 | // for the same oid in parallel. |
| 42 | // If authOkFunc is not nil, implementations must call it as early as possible |
| 43 | // when authentication succeeded, before the whole file content is transferred |
| 44 | type transferImplementationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/transferImplementation# interface { |
| 45 | // WorkerStarting is called when a worker goroutine starts to process jobs |
| 46 | // Implementations can run some startup logic here & return some context if needed |
| 47 | WorkerStartingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/transferImplementation#WorkerStarting.(workerNum int) (interface{}, error) |
| 48 | // WorkerEnding is called when a worker goroutine is shutting down |
| 49 | // Implementations can clean up per-worker resources here, context is as returned from WorkerStarting |
| 50 | WorkerEndingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/transferImplementation#WorkerEnding.(workerNum int, ctx interface{}) |
| 51 | // DoTransfer performs a single transfer within a worker. ctx is any context returned from WorkerStarting |
| 52 | DoTransferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/transferImplementation#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 |
| 53 | } |
| 54 | |
| 55 | const ( |
| 56 | enableHrefRewriteKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/enableHrefRewriteKey. = "lfs.transfer.enablehrefrewrite" |
| 57 | defaultEnableHrefRewritescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/defaultEnableHrefRewrite. = false |
| 58 | ) |
| 59 | |
| 60 | func newAdapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/newAdapterBase().(f *fsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/fs`/.Filesystemscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/fs`/Filesystem#, name string, dir Directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Direction#, ti transferImplementationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/transferImplementation#) *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase# { |
| 61 | return &adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#{ |
| 62 | fsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#fs.: f, |
| 63 | namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#name.: name, |
| 64 | directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#direction.: dir, |
| 65 | transferImplscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#transferImpl.: ti, |
| 66 | jobWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#jobWait.: new(syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.WaitGroupscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#), |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | func (a *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#) Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Name().() string { |
| 71 | return a.namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#name. |
| 72 | } |
| 73 | |
| 74 | func (a *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#) Directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Direction().() Directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Direction# { |
| 75 | return a.directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#direction. |
| 76 | } |
| 77 | |
| 78 | func (a *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#) Beginscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Begin().(cfg AdapterConfigscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/AdapterConfig#, cb ProgressCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ProgressCallback#) error { |
| 79 | a.apiClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#apiClient. = cfg.APIClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/AdapterConfig#APIClient.() |
| 80 | a.remotescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#remote. = cfg.Remotescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/AdapterConfig#Remote.() |
| 81 | a.cbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#cb. = cb |
| 82 | a.jobChanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#jobChan. = make(chan *jobscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#, 100) |
| 83 | a.debuggingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#debugging. = a.apiClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#apiClient..OSEnvscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#OSEnv().().Boolscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#Bool.("GIT_TRANSFER_TRACE", false) || |
| 84 | a.apiClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#apiClient..OSEnvscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#OSEnv().().Boolscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#Bool.("GIT_CURL_VERBOSE", false) |
| 85 | maxConcurrency := cfg.ConcurrentTransfersscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/AdapterConfig#ConcurrentTransfers.() |
| 86 | |
| 87 | a.Tracescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Trace().("xfer: adapter %q Begin() with %d workers", a.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Name().(), maxConcurrency) |
| 88 | |
| 89 | a.workerWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#workerWait..Addscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Add().(maxConcurrency) |
| 90 | a.authWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#authWait..Addscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Add().(1) |
| 91 | for i := 0; i < maxConcurrency; i++ { |
| 92 | ctx, err := a.transferImplscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#transferImpl..WorkerStartingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/transferImplementation#WorkerStarting.(i) |
| 93 | if err != nil { |
| 94 | return err |
| 95 | } |
| 96 | go a.workerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#worker().(i, ctx) |
| 97 | } |
| 98 | a.Tracescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Trace().("xfer: adapter %q started", a.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Name().()) |
| 99 | return nil |
| 100 | } |
| 101 | |
| 102 | type jobscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job# struct { |
| 103 | Tscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#T. *Transferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer# |
| 104 | |
| 105 | resultsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#results. chan<- TransferResultscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferResult# |
| 106 | wgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#wg. *syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.WaitGroupscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup# |
| 107 | } |
| 108 | |
| 109 | func (j *jobscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#) Donescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#Done().(err error) { |
| 110 | j.resultsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#results. <- TransferResultscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferResult#{j.Tscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#T., err} |
| 111 | j.wgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#wg..Donescip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Done().() |
| 112 | } |
| 113 | |
| 114 | func (a *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#) Addscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Add().(transfers ...*Transferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#) <-chan TransferResultscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferResult# { |
| 115 | results := make(chan TransferResultscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/TransferResult#, len(transfers)) |
| 116 | |
| 117 | a.jobWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#jobWait..Addscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Add().(len(transfers)) |
| 118 | |
| 119 | go func() { |
| 120 | for _, t := range transfers { |
| 121 | a.jobChanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#jobChan. <- &jobscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#{t, results, a.jobWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#jobWait.} |
| 122 | } |
| 123 | a.jobWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#jobWait..Waitscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Wait().() |
| 124 | |
| 125 | close(results) |
| 126 | }() |
| 127 | |
| 128 | return results |
| 129 | } |
| 130 | |
| 131 | func (a *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#) Endscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#End().() { |
| 132 | a.Tracescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Trace().("xfer: adapter %q End()", a.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Name().()) |
| 133 | |
| 134 | a.jobWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#jobWait..Waitscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Wait().() |
| 135 | close(a.jobChanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#jobChan.) |
| 136 | |
| 137 | // wait for all transfers to complete |
| 138 | a.workerWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#workerWait..Waitscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Wait().() |
| 139 | |
| 140 | a.Tracescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Trace().("xfer: adapter %q stopped", a.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Name().()) |
| 141 | } |
| 142 | |
| 143 | func (a *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#) Tracescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Trace().(format string, args ...interface{}) { |
| 144 | if !a.debuggingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#debugging. { |
| 145 | return |
| 146 | } |
| 147 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().(format, args...) |
| 148 | } |
| 149 | |
| 150 | // worker function, many of these run per adapter |
| 151 | func (a *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#) workerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#worker().(workerNum int, ctx interface{}) { |
| 152 | a.Tracescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Trace().("xfer: adapter %q worker %d starting", a.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Name().(), workerNum) |
| 153 | waitForAuth := workerNum > 0 |
| 154 | signalAuthOnResponse := workerNum == 0 |
| 155 | |
| 156 | // First worker is the only one allowed to start immediately |
| 157 | // The rest wait until successful response from 1st worker to |
| 158 | // make sure only 1 login prompt is presented if necessary |
| 159 | // Deliberately outside jobChan processing so we know worker 0 will process 1st item |
| 160 | if waitForAuth { |
| 161 | a.Tracescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Trace().("xfer: adapter %q worker %d waiting for Auth", a.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Name().(), workerNum) |
| 162 | a.authWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#authWait..Waitscip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Wait().() |
| 163 | a.Tracescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Trace().("xfer: adapter %q worker %d auth signal received", a.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Name().(), workerNum) |
| 164 | } |
| 165 | |
| 166 | for job := range a.jobChanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#jobChan. { |
| 167 | t := job.Tscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#T. |
| 168 | |
| 169 | var authCallback func() |
| 170 | if signalAuthOnResponse { |
| 171 | authCallback = func() { |
| 172 | a.authWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#authWait..Donescip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Done().() |
| 173 | signalAuthOnResponse = false |
| 174 | } |
| 175 | } |
| 176 | a.Tracescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Trace().("xfer: adapter %q worker %d processing job for %q", a.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Name().(), workerNum, t.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid.) |
| 177 | |
| 178 | // Actual transfer happens here |
| 179 | var err error |
| 180 | if t.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Size. < 0 { |
| 181 | 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().("object %q has invalid size (got: %d)", t.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid., t.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Size.)) |
| 182 | } else { |
| 183 | err = a.transferImplscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#transferImpl..DoTransferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/transferImplementation#DoTransfer.(ctx, t, a.cbscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#cb., authCallback) |
| 184 | } |
| 185 | |
| 186 | // Mark the job as completed, and alter all listeners |
| 187 | job.Donescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/job#Done().(err) |
| 188 | |
| 189 | a.Tracescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Trace().("xfer: adapter %q worker %d finished job for %q", a.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Name().(), workerNum, t.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid.) |
| 190 | } |
| 191 | // This will only happen if no jobs were submitted; just wake up all workers to finish |
| 192 | if signalAuthOnResponse { |
| 193 | a.authWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#authWait..Donescip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Done().() |
| 194 | } |
| 195 | a.Tracescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Trace().("xfer: adapter %q worker %d stopping", a.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#Name().(), workerNum) |
| 196 | a.transferImplscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#transferImpl..WorkerEndingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/transferImplementation#WorkerEnding.(workerNum, ctx) |
| 197 | a.workerWaitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#workerWait..Donescip-go gomod github.com/golang/go/src go1.25.0 sync/WaitGroup#Done().() |
| 198 | } |
| 199 | |
| 200 | var httpREscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/httpRE. = regexpscip-go gomod github.com/golang/go/src go1.25.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.25.0 regexp/MustCompile().(`\Ahttps?://`) |
| 201 | |
| 202 | func (a *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#) newHTTPRequestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#newHTTPRequest().(method string, rel *Actionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Action#) (*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#, error) { |
| 203 | enableRewrite := 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().().Boolscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#Bool.(enableHrefRewriteKeyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/enableHrefRewriteKey., defaultEnableHrefRewritescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/defaultEnableHrefRewrite.) |
| 204 | |
| 205 | href := rel.Hrefscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Action#Href. |
| 206 | if enableRewrite { |
| 207 | href = a.apiClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#apiClient..Endpointsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Endpoints..NewEndpointscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/EndpointFinder#NewEndpoint.(a.directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#direction..Stringscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Direction#String().(), rel.Hrefscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Action#Href.).Urlscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Endpoint#Url. |
| 208 | } |
| 209 | |
| 210 | if !httpREscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/httpRE..MatchStringscip-go gomod github.com/golang/go/src go1.25.0 regexp/Regexp#MatchString().(href) { |
| 211 | urlfragment := 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().(href, "?", 2)[0] |
| 212 | return nil, 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().("missing protocol: %q", urlfragment)) |
| 213 | } |
| 214 | |
| 215 | req, err := httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.NewRequestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/NewRequest().(method, href, nil) |
| 216 | if err != nil { |
| 217 | return nil, err |
| 218 | } |
| 219 | |
| 220 | for key, value := range rel.Headerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Action#Header. { |
| 221 | 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().(key, value) |
| 222 | } |
| 223 | |
| 224 | return req, nil |
| 225 | } |
| 226 | |
| 227 | func (a *adapterBasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#) doHTTPscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#doHTTP().(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) { |
| 228 | if t.Authenticatedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Authenticated. { |
| 229 | return a.apiClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#apiClient..Doscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Do().(req) |
| 230 | } |
| 231 | endpoint := endpointURLscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/endpointURL().(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().(), t.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid.) |
| 232 | return a.apiClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#apiClient..DoWithAuthNoRetryscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#DoWithAuthNoRetry().(a.remotescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#remote., a.apiClientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/adapterBase#apiClient..Endpointsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/Client#Endpoints..AccessForscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfsapi`/EndpointFinder#AccessFor.(endpoint), req) |
| 233 | } |
| 234 | |
| 235 | func advanceCallbackProgressscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/advanceCallbackProgress().(cb ProgressCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ProgressCallback#, t *Transferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#, numBytes int64) { |
| 236 | if cb != nil { |
| 237 | // Must split into max int sizes since read count is int |
| 238 | const maxInt = int(^uint(0) >> 1) |
| 239 | for read := int64(0); read < numBytes; { |
| 240 | remainder := numBytes - read |
| 241 | if remainder > int64(maxInt) { |
| 242 | read += int64(maxInt) |
| 243 | cb(t.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Name., t.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Size., read, maxInt) |
| 244 | } else { |
| 245 | read += remainder |
| 246 | cb(t.Namescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Name., t.Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Size., read, int(remainder)) |
| 247 | } |
| 248 | |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | func endpointURLscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/endpointURL().(rawurl, oid string) string { |
| 254 | return stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Splitscip-go gomod github.com/golang/go/src go1.25.0 strings/Split().(rawurl, oid)[0] |
| 255 | } |