mirror of https://github.com/Xhofe/alist
🔧 close #519 customize temp dir
parent
e90b979d15
commit
228e6d10e7
|
@ -10,10 +10,6 @@ import (
|
||||||
|
|
||||||
// InitConf init config
|
// InitConf init config
|
||||||
func InitConf() {
|
func InitConf() {
|
||||||
err := os.MkdirAll("data/temp", 0700)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("create temp dir error: %s", err.Error())
|
|
||||||
}
|
|
||||||
log.Infof("reading config file: %s", conf.ConfigFile)
|
log.Infof("reading config file: %s", conf.ConfigFile)
|
||||||
if !utils.Exists(conf.ConfigFile) {
|
if !utils.Exists(conf.ConfigFile) {
|
||||||
log.Infof("config file not exists, creating default config file")
|
log.Infof("config file not exists, creating default config file")
|
||||||
|
@ -25,8 +21,7 @@ func InitConf() {
|
||||||
if !utils.WriteToJson(conf.ConfigFile, conf.Conf) {
|
if !utils.WriteToJson(conf.ConfigFile, conf.Conf) {
|
||||||
log.Fatalf("failed to create default config file")
|
log.Fatalf("failed to create default config file")
|
||||||
}
|
}
|
||||||
return
|
} else {
|
||||||
}
|
|
||||||
config, err := ioutil.ReadFile(conf.ConfigFile)
|
config, err := ioutil.ReadFile(conf.ConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("reading config file error:%s", err.Error())
|
log.Fatalf("reading config file error:%s", err.Error())
|
||||||
|
@ -47,3 +42,8 @@ func InitConf() {
|
||||||
log.Fatalf("update config struct error: %s", err.Error())
|
log.Fatalf("update config struct error: %s", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
err := os.MkdirAll(conf.Conf.TempDir, 0700)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("create temp dir error: %s", err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ type Config struct {
|
||||||
Database Database `json:"database"`
|
Database Database `json:"database"`
|
||||||
Scheme Scheme `json:"scheme"`
|
Scheme Scheme `json:"scheme"`
|
||||||
Cache CacheConfig `json:"cache"`
|
Cache CacheConfig `json:"cache"`
|
||||||
|
TempDir string `json:"temp_dir"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultConfig() *Config {
|
func DefaultConfig() *Config {
|
||||||
|
@ -37,6 +38,7 @@ func DefaultConfig() *Config {
|
||||||
Address: "0.0.0.0",
|
Address: "0.0.0.0",
|
||||||
Port: 5244,
|
Port: 5244,
|
||||||
Assets: "jsdelivr",
|
Assets: "jsdelivr",
|
||||||
|
TempDir: "data/temp",
|
||||||
Database: Database{
|
Database: Database{
|
||||||
Type: "sqlite3",
|
Type: "sqlite3",
|
||||||
Port: 0,
|
Port: 0,
|
||||||
|
|
Loading…
Reference in New Issue