diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 7c7a43944f09..321be1a4b7fc 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -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 ;; diff --git a/modules/lfs/http_client.go b/modules/lfs/http_client.go index 4859fe61e1db..6813d44ffccf 100644 --- a/modules/lfs/http_client.go +++ b/modules/lfs/http_client.go @@ -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 { @@ -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 { diff --git a/modules/setting/lfs.go b/modules/setting/lfs.go index 6bdcbed91d90..1e281fec27a2 100644 --- a/modules/setting/lfs.go +++ b/modules/setting/lfs.go @@ -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 }{} @@ -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 {