mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Add new [lfs_client].BATCH_SIZE and [server].LFS_MAX_BATCH_SIZE config settings. (#32307)
This contains two backwards-compatible changes: * in the lfs http_client, the number of lfs oids requested per batch is loaded from lfs_client#BATCH_SIZE and defaulted to the previous value of 20 * in the lfs server/service, the max number of lfs oids allowed in a batch api request is loaded from server#LFS_MAX_BATCH_SIZE and defaults to 'nil' which equates to the previous behavior of 'infinite' This fixes #32306 --------- Signed-off-by: Royce Remer <royceremer@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -10,7 +10,10 @@ import ( | ||||
| 	"code.gitea.io/gitea/modules/generate" | ||||
| ) | ||||
|  | ||||
| // LFS represents the configuration for Git LFS | ||||
| // LFS represents the server-side configuration for Git LFS. | ||||
| // Ideally these options should be in a section like "[lfs_server]", | ||||
| // but they are in "[server]" section due to historical reasons. | ||||
| // Could be refactored in the future while keeping backwards compatibility. | ||||
| var LFS = struct { | ||||
| 	StartServer    bool          `ini:"LFS_START_SERVER"` | ||||
| 	AllowPureSSH   bool          `ini:"LFS_ALLOW_PURE_SSH"` | ||||
| @@ -18,15 +21,21 @@ 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"` | ||||
| 	MaxBatchSize   int           `ini:"LFS_MAX_BATCH_SIZE"` | ||||
|  | ||||
| 	Storage *Storage | ||||
| }{} | ||||
|  | ||||
| // LFSClient represents configuration for Gitea's LFS clients, for example: mirroring upstream Git LFS | ||||
| var LFSClient = struct { | ||||
| 	BatchSize int `ini:"BATCH_SIZE"` | ||||
| }{} | ||||
|  | ||||
| func loadLFSFrom(rootCfg ConfigProvider) error { | ||||
| 	mustMapSetting(rootCfg, "lfs_client", &LFSClient) | ||||
|  | ||||
| 	mustMapSetting(rootCfg, "server", &LFS) | ||||
| 	sec := rootCfg.Section("server") | ||||
| 	if err := sec.MapTo(&LFS); err != nil { | ||||
| 		return fmt.Errorf("failed to map LFS settings: %v", err) | ||||
| 	} | ||||
|  | ||||
| 	lfsSec, _ := rootCfg.GetSection("lfs") | ||||
|  | ||||
| @@ -53,6 +62,10 @@ func loadLFSFrom(rootCfg ConfigProvider) error { | ||||
| 		LFS.LocksPagingNum = 50 | ||||
| 	} | ||||
|  | ||||
| 	if LFSClient.BatchSize < 1 { | ||||
| 		LFSClient.BatchSize = 20 | ||||
| 	} | ||||
|  | ||||
| 	LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(24 * time.Hour) | ||||
|  | ||||
| 	if !LFS.StartServer || !InstallLock { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user