Sfoglia il codice sorgente

修复配置文件的根目录获取和设置的问题

Signed-off-by: 716 <[email protected]>
716 3 anni fa
parent
commit
dd25a816be

+ 3 - 0
cmd/chinesesubfinder/main.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"github.com/allanpk716/ChineseSubFinder/internal/backend"
 	"github.com/allanpk716/ChineseSubFinder/internal/logic/cron_helper"
+	"github.com/allanpk716/ChineseSubFinder/internal/pkg/folder_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
@@ -18,6 +19,8 @@ func init() {
 
 	global_value.AppVersion = AppVersion
 
+	global_value.ConfigRootDirFPath = folder_helper.GetConfigRootDirFPath()
+
 	if my_util.OSCheck() == false {
 		panic(`You should search runtime.GOOS in the project, Implement unimplemented function`)
 	}

+ 1 - 1
internal/dao/init.go

@@ -76,7 +76,7 @@ func InitDb() error {
 }
 
 func getDbName() string {
-	return folder_helper.GetConfigRootDirFPath() + dbFileName
+	return filepath.Join(folder_helper.GetConfigRootDirFPath(), dbFileName)
 }
 
 var (

+ 2 - 1
internal/logic/forced_scan_and_down_sub/forced_scan_and_down_sub.go

@@ -6,6 +6,7 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/folder_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
 	"os"
+	"path/filepath"
 )
 
 // CheckSpeFile 目标是检测特定的文件,找到后,先删除,返回一个标志位用于后面的逻辑
@@ -30,7 +31,7 @@ you needd implement getSpeFileName() in internal/logic/forced_scan_and_down_sub/
 
 func getSpeFileName() string {
 
-	return folder_helper.GetConfigRootDirFPath() + specialFileNameWindows
+	return filepath.Join(folder_helper.GetConfigRootDirFPath(), specialFileNameWindows)
 }
 
 /*

+ 1 - 2
internal/logic/pre_download_process/pre_download_proces.go

@@ -8,7 +8,6 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/internal/logic/sub_supplier/subhd"
 	"github.com/allanpk716/ChineseSubFinder/internal/logic/sub_supplier/xunlei"
 	"github.com/allanpk716/ChineseSubFinder/internal/logic/sub_supplier/zimuku"
-	"github.com/allanpk716/ChineseSubFinder/internal/pkg/folder_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/hot_fix"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
@@ -42,7 +41,7 @@ func (p *PreDownloadProcess) Init() *PreDownloadProcess {
 	p.stageName = stageNameInit
 	// ------------------------------------------------------------------------
 	// 初始化全局变量
-	global_value.Init(folder_helper.GetConfigRootDirFPath(), settings.GetSettings().AdvancedSettings.CustomVideoExts)
+	global_value.Init(settings.GetSettings().AdvancedSettings.CustomVideoExts)
 	// ------------------------------------------------------------------------
 	// 初始化通知缓存模块
 	notify_center.Notify = notify_center.NewNotifyCenter(settings.GetSettings().DeveloperSettings.BarkServerAddress)

+ 2 - 1
internal/logic/restore_fix_timeline_bk/restore_fix_timeline_bk.go

@@ -4,6 +4,7 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/folder_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
 	"os"
+	"path/filepath"
 )
 
 // CheckSpeFile 目标是检测特定的文件,找到后,先删除,返回一个标志位用于后面的逻辑
@@ -24,7 +25,7 @@ func CheckSpeFile() (bool, error) {
 }
 
 func getSpeFileName() string {
-	return folder_helper.GetConfigRootDirFPath() + specialFileName
+	return filepath.Join(folder_helper.GetConfigRootDirFPath(), specialFileName)
 }
 
 /*

+ 3 - 3
internal/pkg/folder_helper/folder.go

@@ -384,7 +384,7 @@ const (
 
 // 配置文件的位置信息,这个会根据系统版本做区分
 const (
-	configDirRootFPathWindows = "./"                         // Windows 就是在当前的程序目录
-	configDirRootFPathLinux   = "/config/"                   // Linux 是在 /config 下
-	configDirRootFPathDarwin  = "/.config/chinesesubfinder/" // Darwin 是在 os.UserHomeDir()/.config/chinesesubfinder/ 下
+	configDirRootFPathWindows = "."                         // Windows 就是在当前的程序目录
+	configDirRootFPathLinux   = "/config"                   // Linux 是在 /config 下
+	configDirRootFPathDarwin  = "/.config/chinesesubfinder" // Darwin 是在 os.UserHomeDir()/.config/chinesesubfinder/ 下
 )

+ 1 - 2
internal/pkg/global_value/global_value.go

@@ -1,7 +1,6 @@
 package global_value
 
-func Init(configRootDirFPath string, customExts []string) {
-	ConfigRootDirFPath = configRootDirFPath
+func Init(customExts []string) {
 	DefDebugFolder = ""
 	DefTmpFolder = ""
 	DefSubFixCacheFolder = ""