MCPcopy
hub / github.com/ChineseSubFinder/ChineseSubFinder / Get

Function Get

pkg/settings/settings.go:27–73  ·  view source on GitHub ↗

Get 获取 Settings 的实例

(reloadSettings ...bool)

Source from the content-addressed store, hash-verified

25
26// Get 获取 Settings 的实例
27func Get(reloadSettings ...bool) *Settings {
28
29 _settingsLocker.Lock()
30 defer _settingsLocker.Unlock()
31
32 if _settings == nil {
33
34 _settingsOnce.Do(func() {
35
36 if _configRootPath == "" {
37 panic("请先调用 SetConfigRootPath 设置配置文件的根目录")
38 }
39 _settings = NewSettings(_configRootPath)
40 if isFile(_settings.configFPath) == false {
41
42 err := os.MkdirAll(filepath.Dir(_settings.configFPath), os.ModePerm)
43 if err != nil {
44 panic("创建配置文件目录失败," + err.Error())
45 }
46 // 配置文件不存在,新建一个空白的
47 err = _settings.Save()
48 if err != nil {
49 panic("Can't Save Config File:" + configName + " Error: " + err.Error())
50 }
51 } else {
52 // 读取存在的文件
53 err := _settings.read()
54 if err != nil {
55 panic("Can't Read Config File:" + configName + " Error: " + err.Error())
56 }
57 // 因为 SuppliersSettings 中每个网站的 searchUrl 参数没有开放更改,所以如果有变动,需要重新设置
58 _settings.AdvancedSettings.SuppliersSettings.ReSetSearchUrl()
59 }
60 })
61 // 是否需要重新读取配置信息,这个可能在每次保存配置文件后需要操作
62 if len(reloadSettings) >= 1 {
63 if reloadSettings[0] == true {
64 err := _settings.read()
65 if err != nil {
66 panic("Can't Read Config File:" + configName + " Error: " + err.Error())
67 }
68 }
69 }
70
71 }
72 return _settings
73}
74
75// SetFullNewSettings 从 Web 端传入新的 Settings 完整设置
76func SetFullNewSettings(inSettings *Settings) error {

Callers 15

IsWantedVideoExtDefFunction · 0.92
RefreshMainListMethod · 0.92
queueDownloaderCloudMethod · 0.92
queueDownloaderLocalMethod · 0.92
oneVideoSelectBestSubMethod · 0.92
movieDlFuncMethod · 0.92
seriesDlFuncMethod · 0.92
NewDownloaderFunction · 0.92
SupplierCheckMethod · 0.92
processMethod · 0.92
NewEmbyApiFunction · 0.92

Calls 7

NewSettingsFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
SaveMethod · 0.80
ReSetSearchUrlMethod · 0.80
isFileFunction · 0.70
readMethod · 0.45

Tested by 4

defInstanceFunction · 0.74
defInstanceFunction · 0.74
defInstanceFunction · 0.74