Skip to content

Commit

Permalink
Add new LFS_BATCH_SIZE configuration setting.
Browse files Browse the repository at this point in the history
This is a backwards-compatible change to the lfs http_client. When unconfigured or <1, a batch size of 20 will be used (the previous hardcoded value).

This fixes #32306

Signed-off-by: Royce Remer <[email protected]>
  • Loading branch information
rremer committed Oct 21, 2024
1 parent d638067 commit 129b5d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ RUN_USER = ; git
;; Maximum number of locks returned per page
;LFS_LOCKS_PAGING_NUM = 50
;;
;; Maximum number of concurrent LFS object upload/downloads and count to request per batch request
;LFS_BATCH_SIZE = 20
;;
;; Allow graceful restarts using SIGHUP to fork
;ALLOW_GRACEFUL_RESTARTS = true
;;
Expand Down
5 changes: 2 additions & 3 deletions modules/lfs/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import (
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/proxy"
"code.gitea.io/gitea/modules/setting"
)

const httpBatchSize = 20

// HTTPClient is used to communicate with the LFS server
// https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md
type HTTPClient struct {
Expand All @@ -30,7 +29,7 @@ type HTTPClient struct {

// BatchSize returns the preferred size of batchs to process
func (c *HTTPClient) BatchSize() int {
return httpBatchSize
return setting.LFS.BatchSize
}

func newHTTPClient(endpoint *url.URL, httpTransport *http.Transport) *HTTPClient {
Expand Down
5 changes: 5 additions & 0 deletions modules/setting/lfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var LFS = struct {
HTTPAuthExpiry time.Duration `ini:"LFS_HTTP_AUTH_EXPIRY"`
MaxFileSize int64 `ini:"LFS_MAX_FILE_SIZE"`
LocksPagingNum int `ini:"LFS_LOCKS_PAGING_NUM"`
BatchSize int `ini:"LFS_BATCH_SIZE"`

Storage *Storage
}{}
Expand Down Expand Up @@ -53,6 +54,10 @@ func loadLFSFrom(rootCfg ConfigProvider) error {
LFS.LocksPagingNum = 50
}

if LFS.BatchSize < 1 {
LFS.BatchSize = 20
}

LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(24 * time.Hour)

if !LFS.StartServer || !InstallLock {
Expand Down

0 comments on commit 129b5d2

Please sign in to comment.