Skip to content

Commit 01b4cb2

Browse files
committed
add APP_TEMP_PATH
1 parent e40bfb8 commit 01b4cb2

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

custom/conf/app.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ RUN_USER = ; git
287287
;; Default path for App data
288288
;APP_DATA_PATH = data ; relative paths will be made absolute with _`AppWorkPath`_
289289
;;
290+
;; Base path for App's temp files, leave empty to use the managed tmp directory in APP_DATA_PATH
291+
;APP_TEMP_PATH =
292+
;;
290293
;; Enable gzip compression for runtime-generated content, static resources excluded
291294
;ENABLE_GZIP = false
292295
;;

modules/setting/path.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ func InitWorkPathAndCfgProvider(getEnvFn func(name string) string, args ArgWorkP
199199
}
200200

201201
func AppDataTempDir(sub string) *tempdir.TempDir {
202+
if AppTempPath != "" {
203+
return tempdir.New(AppDataPath, "gitea-tmp/"+sub)
204+
}
202205
if AppDataPath == "" {
203206
panic("setting.AppDataPath is not set")
204207
}

modules/setting/server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ var (
6060
// AssetVersion holds a opaque value that is used for cache-busting assets
6161
AssetVersion string
6262

63+
AppTempPath string
64+
6365
Protocol Scheme
6466
UseProxyProtocol bool // `ini:"USE_PROXY_PROTOCOL"`
6567
ProxyProtocolTLSBridging bool //`ini:"PROXY_PROTOCOL_TLS_BRIDGING"`
@@ -338,6 +340,13 @@ func loadServerFrom(rootCfg ConfigProvider) {
338340
}
339341
}
340342

343+
AppTempPath = sec.Key("APP_TEMP_PATH").String()
344+
if AppTempPath != "" {
345+
if _, err := os.Stat(AppTempPath); err != nil {
346+
log.Fatal("APP_TEMP_PATH %q is not accessible: %v", AppTempPath, err)
347+
}
348+
}
349+
341350
EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
342351
EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false)
343352
PprofDataPath = sec.Key("PPROF_DATA_PATH").MustString(filepath.Join(AppWorkPath, "data/tmp/pprof"))

0 commit comments

Comments
 (0)