added cache folder check
This commit is contained in:
parent
44e9d3356f
commit
ff84d49ff3
2 changed files with 16 additions and 12 deletions
20
config.go
20
config.go
|
@ -115,15 +115,13 @@ func createConfig() error {
|
|||
ramDurationStr = strings.TrimSpace(ramDurationStr)
|
||||
if ramDurationStr == "" {
|
||||
config.RamCache.Duration = defaultConfig.RamCache.Duration
|
||||
config.RamCacheEnabled = true
|
||||
} else if ramDurationStr == "0h" {
|
||||
config.RamCacheEnabled = false
|
||||
config.RamCacheEnabled = defaultConfig.RamCacheEnabled
|
||||
} else {
|
||||
ramDuration, err := time.ParseDuration(ramDurationStr)
|
||||
if err != nil {
|
||||
if err != nil || ramDuration == 0 {
|
||||
printWarn("Invalid duration, using default (6h).")
|
||||
config.RamCache.Duration = defaultConfig.RamCache.Duration
|
||||
config.RamCacheEnabled = true
|
||||
config.RamCacheEnabled = defaultConfig.RamCacheEnabled
|
||||
} else {
|
||||
config.RamCache.Duration = ramDuration
|
||||
config.RamCacheEnabled = true
|
||||
|
@ -151,18 +149,16 @@ func createConfig() error {
|
|||
driveDurationStr = strings.TrimSpace(driveDurationStr)
|
||||
if driveDurationStr == "" {
|
||||
config.DriveCache.Duration = defaultConfig.DriveCache.Duration
|
||||
config.DriveCacheEnabled = config.DriveCache.Duration > 0
|
||||
} else if driveDurationStr == "0h" {
|
||||
config.DriveCacheEnabled = false
|
||||
config.DriveCacheEnabled = defaultConfig.DriveCacheEnabled
|
||||
} else {
|
||||
driveDuration, err := time.ParseDuration(driveDurationStr)
|
||||
if err != nil {
|
||||
printWarn("Invalid duration, using default (48h).")
|
||||
if err != nil || driveDuration == 0 {
|
||||
printErr("Invalid duration, using default (48h).")
|
||||
config.DriveCache.Duration = defaultConfig.DriveCache.Duration
|
||||
config.DriveCacheEnabled = config.DriveCache.Duration > 0
|
||||
config.DriveCacheEnabled = defaultConfig.DriveCacheEnabled
|
||||
} else {
|
||||
config.DriveCache.Duration = driveDuration
|
||||
config.DriveCacheEnabled = config.DriveCache.Duration > 0
|
||||
config.DriveCacheEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue