Skip to content

Commit 129b5d2

Browse files
committed
Add new LFS_BATCH_SIZE configuration setting.
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]>
1 parent d638067 commit 129b5d2

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

custom/conf/app.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ RUN_USER = ; git
324324
;; Maximum number of locks returned per page
325325
;LFS_LOCKS_PAGING_NUM = 50
326326
;;
327+
;; Maximum number of concurrent LFS object upload/downloads and count to request per batch request
328+
;LFS_BATCH_SIZE = 20
329+
;;
327330
;; Allow graceful restarts using SIGHUP to fork
328331
;ALLOW_GRACEFUL_RESTARTS = true
329332
;;

modules/lfs/http_client.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ import (
1616
"code.gitea.io/gitea/modules/json"
1717
"code.gitea.io/gitea/modules/log"
1818
"code.gitea.io/gitea/modules/proxy"
19+
"code.gitea.io/gitea/modules/setting"
1920
)
2021

21-
const httpBatchSize = 20
22-
2322
// HTTPClient is used to communicate with the LFS server
2423
// https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md
2524
type HTTPClient struct {
@@ -30,7 +29,7 @@ type HTTPClient struct {
3029

3130
// BatchSize returns the preferred size of batchs to process
3231
func (c *HTTPClient) BatchSize() int {
33-
return httpBatchSize
32+
return setting.LFS.BatchSize
3433
}
3534

3635
func newHTTPClient(endpoint *url.URL, httpTransport *http.Transport) *HTTPClient {

modules/setting/lfs.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var LFS = struct {
1818
HTTPAuthExpiry time.Duration `ini:"LFS_HTTP_AUTH_EXPIRY"`
1919
MaxFileSize int64 `ini:"LFS_MAX_FILE_SIZE"`
2020
LocksPagingNum int `ini:"LFS_LOCKS_PAGING_NUM"`
21+
BatchSize int `ini:"LFS_BATCH_SIZE"`
2122

2223
Storage *Storage
2324
}{}
@@ -53,6 +54,10 @@ func loadLFSFrom(rootCfg ConfigProvider) error {
5354
LFS.LocksPagingNum = 50
5455
}
5556

57+
if LFS.BatchSize < 1 {
58+
LFS.BatchSize = 20
59+
}
60+
5661
LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(24 * time.Hour)
5762

5863
if !LFS.StartServer || !InstallLock {

0 commit comments

Comments
 (0)