mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-23 05:44:04 +08:00

* refactor:separate the setting method from the db package to the op package and add the cache * refactor:separate the meta method from the db package to the op package * fix:setting not load database data * refactor:separate the user method from the db package to the op package * refactor:remove user JoinPath error * fix:op package user cache * refactor:fs package list method * fix:tile virtual paths (close #2743) * Revert "refactor:remove user JoinPath error" This reverts commit 4e20daaf9e700da047000d4fd4900abbe05c3848. * clean path directly may lead to unknown behavior * fix: The path of the meta passed in must be prefix of reqPath * chore: rename all virtualPath to mountPath * fix: `getStoragesByPath` and `GetStorageVirtualFilesByPath` is_sub_path: /a/b isn't subpath of /a/bc * fix: don't save setting if hook error Co-authored-by: Noah Hsu <i@nn.ci>
31 lines
516 B
Go
31 lines
516 B
Go
package setting
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/alist-org/alist/v3/internal/op"
|
|
)
|
|
|
|
func GetStr(key string, defaultValue ...string) string {
|
|
val, _ := op.GetSettingItemByKey(key)
|
|
if val == nil {
|
|
if len(defaultValue) > 0 {
|
|
return defaultValue[0]
|
|
}
|
|
return ""
|
|
}
|
|
return val.Value
|
|
}
|
|
|
|
func GetInt(key string, defaultVal int) int {
|
|
i, err := strconv.Atoi(GetStr(key))
|
|
if err != nil {
|
|
return defaultVal
|
|
}
|
|
return i
|
|
}
|
|
|
|
func GetBool(key string) bool {
|
|
return GetStr(key) == "true" || GetStr(key) == "1"
|
|
}
|