-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
43 lines (37 loc) · 1.09 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"os"
"path"
"time"
)
type AppConfig struct {
Port int64 `yaml:"port"`
ApiKey string `yaml:"api_key"`
ApiSecret string `yaml:"api_secret"`
Path string `yaml:"path"`
Debug bool `yaml:"debug"`
Compress bool `yaml:"compress"`
DeleteEmptyDir bool `yaml:"delete_empty_dir"`
EnableDelFileBackup bool `yaml:"enable_del_file_backup"`
DelFileBackupPath string `yaml:"del_file_backup_path"`
DelFileBackupDuration time.Duration `yaml:"del_file_backup_duration"`
}
func createOrUpdateDirs() error {
err := os.MkdirAll(AppCnf.Path, 0755)
if err != nil {
return err
}
if AppCnf.EnableDelFileBackup {
if AppCnf.DelFileBackupDuration == 0 {
AppCnf.DelFileBackupDuration = time.Hour * 72
}
if AppCnf.DelFileBackupPath == "" {
AppCnf.DelFileBackupPath = path.Join(AppCnf.Path, "del_backup")
}
err := os.MkdirAll(AppCnf.DelFileBackupPath, 0755)
if err != nil {
return err
}
}
return nil
}