| 1 | package tqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 5 | "mathscip-go gomod github.com/golang/go/src go1.25.0 math/" |
| 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 | "syncscip-go gomod github.com/golang/go/src go1.25.0 sync/" |
| 9 | "sync/atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/" |
| 10 | "timescip-go gomod github.com/golang/go/src go1.25.0 time/" |
| 11 | |
| 12 | "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`/" |
| 13 | "github.com/git-lfs/git-lfs/v3/tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/" |
| 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/tools/humanizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/" |
| 16 | "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`/" |
| 17 | ) |
| 18 | |
| 19 | // Meter provides a progress bar type output for the TransferQueue. It |
| 20 | // is given an estimated file count and size up front and tracks the number of |
| 21 | // files and bytes transferred as well as the number of files and bytes that |
| 22 | // get skipped because the transfer is unnecessary. |
| 23 | type Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter# struct { |
| 24 | finishedFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#finishedFiles. int64 // int64s must come first for struct alignment |
| 25 | transferringFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#transferringFiles. int64 |
| 26 | estimatedBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#estimatedBytes. int64 |
| 27 | lastBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#lastBytes. int64 |
| 28 | currentBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#currentBytes. int64 |
| 29 | sampleCountscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#sampleCount. uint64 |
| 30 | avgBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#avgBytes. float64 |
| 31 | lastAvgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#lastAvg. timescip-go gomod github.com/golang/go/src go1.25.0 time/.Timescip-go gomod github.com/golang/go/src go1.25.0 time/Time# |
| 32 | estimatedFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#estimatedFiles. int32 |
| 33 | pausedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#paused. uint32 |
| 34 | fileIndexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndex. map[string]int64 // Maps a file name to its transfer number |
| 35 | fileIndexMutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndexMutex. *syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.Mutexscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex# |
| 36 | updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#updates. chan *tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.Updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update# |
| 37 | cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#cfg. *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration# |
| 38 | |
| 39 | DryRunscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#DryRun. bool |
| 40 | Loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Logger. *toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.SyncWriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter# |
| 41 | Directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Direction. Directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Direction# |
| 42 | } |
| 43 | |
| 44 | type envscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/env# interface { |
| 45 | Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/env#Get.(key string) (val string, ok bool) |
| 46 | } |
| 47 | |
| 48 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) LoggerFromEnvscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#LoggerFromEnv().(os envscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/env#) *toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.SyncWriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter# { |
| 49 | name, _ := os.Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/env#Get.("GIT_LFS_PROGRESS") |
| 50 | if len(name) < 1 { |
| 51 | return nil |
| 52 | } |
| 53 | return m.LoggerToFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#LoggerToFile().(name) |
| 54 | } |
| 55 | |
| 56 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) LoggerToFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#LoggerToFile().(name string) *toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.SyncWriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter# { |
| 57 | printErr := func(err string) { |
| 58 | fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintln().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.Stderrscip-go gomod github.com/golang/go/src go1.25.0 os/Stderr., 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().("Error creating progress logger: %s", err)) |
| 59 | } |
| 60 | |
| 61 | if !filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.IsAbsscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/IsAbs().(name) { |
| 62 | printErr(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().("GIT_LFS_PROGRESS must be an absolute path")) |
| 63 | return nil |
| 64 | } |
| 65 | |
| 66 | 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().(filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Dir().(name), m.cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#cfg.); err != nil { |
| 67 | printErr(err.Error()) |
| 68 | return nil |
| 69 | } |
| 70 | |
| 71 | file, 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().(name, osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_WRONLYscip-go gomod github.com/golang/go/src go1.25.0 os/O_WRONLY.|osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_CREATEscip-go gomod github.com/golang/go/src go1.25.0 os/O_CREATE.|osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_APPENDscip-go gomod github.com/golang/go/src go1.25.0 os/O_APPEND., 0666) |
| 72 | if err != nil { |
| 73 | printErr(err.Error()) |
| 74 | return nil |
| 75 | } |
| 76 | |
| 77 | return toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.NewSyncWriterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewSyncWriter().(file) |
| 78 | } |
| 79 | |
| 80 | // NewMeter creates a new Meter. |
| 81 | func NewMeterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/NewMeter().(cfg *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#) *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter# { |
| 82 | m := &Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#{ |
| 83 | fileIndexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndex.: make(map[string]int64), |
| 84 | fileIndexMutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndexMutex.: &syncscip-go gomod github.com/golang/go/src go1.25.0 sync/.Mutexscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#{}, |
| 85 | updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#updates.: make(chan *tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.Updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#), |
| 86 | cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#cfg.: cfg, |
| 87 | } |
| 88 | |
| 89 | return m |
| 90 | } |
| 91 | |
| 92 | // Start begins sending status updates to the optional log file, and stdout. |
| 93 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) Startscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Start().() { |
| 94 | if m == nil { |
| 95 | return |
| 96 | } |
| 97 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.StoreUint32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/StoreUint32().(&m.pausedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#paused., 0) |
| 98 | } |
| 99 | |
| 100 | // Pause stops sending status updates temporarily, until Start() is called again. |
| 101 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) Pausescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Pause().() { |
| 102 | if m == nil { |
| 103 | return |
| 104 | } |
| 105 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.StoreUint32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/StoreUint32().(&m.pausedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#paused., 1) |
| 106 | } |
| 107 | |
| 108 | // Add tells the progress meter that a single file of the given size will |
| 109 | // possibly be transferred. If a file doesn't need to be transferred for some |
| 110 | // reason, be sure to call Skip(int64) with the same size. |
| 111 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) Addscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Add().(size int64) { |
| 112 | if m == nil { |
| 113 | return |
| 114 | } |
| 115 | |
| 116 | defer m.updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#update().(false) |
| 117 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddInt32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddInt32().(&m.estimatedFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#estimatedFiles., 1) |
| 118 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddInt64scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddInt64().(&m.estimatedBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#estimatedBytes., size) |
| 119 | } |
| 120 | |
| 121 | // Skip tells the progress meter that a file of size `size` is being skipped |
| 122 | // because the transfer is unnecessary. |
| 123 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) Skipscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Skip().(size int64) { |
| 124 | if m == nil { |
| 125 | return |
| 126 | } |
| 127 | |
| 128 | defer m.updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#update().(false) |
| 129 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddInt64scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddInt64().(&m.finishedFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#finishedFiles., 1) |
| 130 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddInt64scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddInt64().(&m.currentBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#currentBytes., size) |
| 131 | } |
| 132 | |
| 133 | // StartTransfer tells the progress meter that a transferring file is being |
| 134 | // added to the TransferQueue. |
| 135 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) StartTransferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#StartTransfer().(name string) { |
| 136 | if m == nil { |
| 137 | return |
| 138 | } |
| 139 | |
| 140 | defer m.updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#update().(false) |
| 141 | idx := atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddInt64scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddInt64().(&m.transferringFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#transferringFiles., 1) |
| 142 | m.fileIndexMutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndexMutex..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().() |
| 143 | m.fileIndexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndex.[name] = idx |
| 144 | m.fileIndexMutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndexMutex..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().() |
| 145 | } |
| 146 | |
| 147 | // TransferBytes increments the number of bytes transferred |
| 148 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) TransferBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#TransferBytes().(direction, name string, read, total int64, current int) { |
| 149 | if m == nil { |
| 150 | return |
| 151 | } |
| 152 | |
| 153 | defer m.updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#update().(false) |
| 154 | |
| 155 | now := timescip-go gomod github.com/golang/go/src go1.25.0 time/.Nowscip-go gomod github.com/golang/go/src go1.25.0 time/Now().() |
| 156 | since := now.Subscip-go gomod github.com/golang/go/src go1.25.0 time/Time#Sub().(m.lastAvgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#lastAvg.) |
| 157 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddInt64scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddInt64().(&m.currentBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#currentBytes., int64(current)) |
| 158 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddInt64scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddInt64().(&m.lastBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#lastBytes., int64(current)) |
| 159 | |
| 160 | if since > timescip-go gomod github.com/golang/go/src go1.25.0 time/.Secondscip-go gomod github.com/golang/go/src go1.25.0 time/Second. { |
| 161 | m.lastAvgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#lastAvg. = now |
| 162 | |
| 163 | bps := float64(m.lastBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#lastBytes.) / since.Secondsscip-go gomod github.com/golang/go/src go1.25.0 time/Duration#Seconds().() |
| 164 | |
| 165 | m.avgBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#avgBytes. = (m.avgBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#avgBytes.*float64(m.sampleCountscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#sampleCount.) + bps) / (float64(m.sampleCountscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#sampleCount.) + 1.0) |
| 166 | |
| 167 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.StoreInt64scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/StoreInt64().(&m.lastBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#lastBytes., 0) |
| 168 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddUint64scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddUint64().(&m.sampleCountscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#sampleCount., 1) |
| 169 | } |
| 170 | |
| 171 | m.logBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#logBytes().(direction, name, read, total) |
| 172 | } |
| 173 | |
| 174 | // FinishTransfer increments the finished transfer count |
| 175 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) FinishTransferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#FinishTransfer().(name string) { |
| 176 | if m == nil { |
| 177 | return |
| 178 | } |
| 179 | |
| 180 | defer m.updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#update().(false) |
| 181 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.AddInt64scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/AddInt64().(&m.finishedFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#finishedFiles., 1) |
| 182 | m.fileIndexMutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndexMutex..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().() |
| 183 | delete(m.fileIndexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndex., name) |
| 184 | m.fileIndexMutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndexMutex..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().() |
| 185 | } |
| 186 | |
| 187 | // Flush sends the latest progress update, while leaving the meter active. |
| 188 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) Flushscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Flush().() { |
| 189 | if m == nil { |
| 190 | return |
| 191 | } |
| 192 | |
| 193 | m.updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#update().(true) |
| 194 | } |
| 195 | |
| 196 | // Finish shuts down the Meter. |
| 197 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) Finishscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Finish().() { |
| 198 | if m == nil { |
| 199 | return |
| 200 | } |
| 201 | |
| 202 | m.updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#update().(false) |
| 203 | close(m.updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#updates.) |
| 204 | } |
| 205 | |
| 206 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) Updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Updates().() <-chan *tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.Updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update# { |
| 207 | if m == nil { |
| 208 | return nil |
| 209 | } |
| 210 | return m.updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#updates. |
| 211 | } |
| 212 | |
| 213 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) Throttledscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Throttled().() bool { |
| 214 | return true |
| 215 | } |
| 216 | |
| 217 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#update().(force bool) { |
| 218 | if m.skipUpdatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#skipUpdate().() { |
| 219 | return |
| 220 | } |
| 221 | |
| 222 | m.updatesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#updates. <- &tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.Updatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#{ |
| 223 | Sscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#S.: m.strscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#str().(), |
| 224 | Atscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#At.: timescip-go gomod github.com/golang/go/src go1.25.0 time/.Nowscip-go gomod github.com/golang/go/src go1.25.0 time/Now().(), |
| 225 | Forcescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/Update#Force.: force, |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) skipUpdatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#skipUpdate().() bool { |
| 230 | return m.DryRunscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#DryRun. || |
| 231 | m.estimatedFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#estimatedFiles. == 0 || |
| 232 | atomicscip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/.LoadUint32scip-go gomod github.com/golang/go/src go1.25.0 `sync/atomic`/LoadUint32().(&m.pausedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#paused.) == 1 |
| 233 | } |
| 234 | |
| 235 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) strscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#str().() string { |
| 236 | // (Uploading|Downloading) LFS objects: 100% (10/10) 100 MiB | 10 MiB/s |
| 237 | percentage := 100 * float64(m.finishedFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#finishedFiles.) / float64(m.estimatedFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#estimatedFiles.) |
| 238 | |
| 239 | return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("%s: %3.f%% (%d/%d), %s | %s", |
| 240 | m.Directionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Direction..Progressscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Direction#Progress().(), |
| 241 | percentage, |
| 242 | m.finishedFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#finishedFiles., m.estimatedFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#estimatedFiles., |
| 243 | humanizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/.FormatBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/FormatBytes().(clampscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/clamp().(m.currentBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#currentBytes.)), |
| 244 | humanizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/.FormatByteRatescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools/humanize`/FormatByteRate().(clampfscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/clampf().(m.avgBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#avgBytes.), timescip-go gomod github.com/golang/go/src go1.25.0 time/.Secondscip-go gomod github.com/golang/go/src go1.25.0 time/Second.)) |
| 245 | } |
| 246 | |
| 247 | // clamp clamps the given "x" within the acceptable domain of the uint64 integer |
| 248 | // type, so as to prevent over- and underflow. |
| 249 | func clampscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/clamp().(x int64) uint64 { |
| 250 | if x < 0 { |
| 251 | return 0 |
| 252 | } |
| 253 | if x > mathscip-go gomod github.com/golang/go/src go1.25.0 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.25.0 math/MaxInt64. { |
| 254 | return mathscip-go gomod github.com/golang/go/src go1.25.0 math/.MaxUint64scip-go gomod github.com/golang/go/src go1.25.0 math/MaxUint64. |
| 255 | } |
| 256 | return uint64(x) |
| 257 | } |
| 258 | |
| 259 | func clampfscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/clampf().(x float64) uint64 { |
| 260 | if x < 0 { |
| 261 | return 0 |
| 262 | } |
| 263 | if x > mathscip-go gomod github.com/golang/go/src go1.25.0 math/.MaxUint64scip-go gomod github.com/golang/go/src go1.25.0 math/MaxUint64. { |
| 264 | return mathscip-go gomod github.com/golang/go/src go1.25.0 math/.MaxUint64scip-go gomod github.com/golang/go/src go1.25.0 math/MaxUint64. |
| 265 | } |
| 266 | return uint64(x) |
| 267 | } |
| 268 | |
| 269 | func (m *Meterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#) logBytesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#logBytes().(direction, name string, read, total int64) { |
| 270 | m.fileIndexMutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndexMutex..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().() |
| 271 | idx := m.fileIndexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndex.[name] |
| 272 | logger := m.Loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Logger. |
| 273 | m.fileIndexMutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndexMutex..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().() |
| 274 | if logger == nil { |
| 275 | return |
| 276 | } |
| 277 | |
| 278 | readFraction := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.FormatFractionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/FormatFraction().(read, total) |
| 279 | line := fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("%s %d/%d %s %s\n", direction, idx, m.estimatedFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#estimatedFiles., readFraction, name) |
| 280 | if err := m.Loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Logger..Writescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SyncWriter#Write().([]byte(line)); err != nil { |
| 281 | m.fileIndexMutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndexMutex..Lockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Lock().() |
| 282 | m.Loggerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#Logger. = nil |
| 283 | m.fileIndexMutexscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Meter#fileIndexMutex..Unlockscip-go gomod github.com/golang/go/src go1.25.0 sync/Mutex#Unlock().() |
| 284 | } |
| 285 | } |