new: Added the option to automatically pull in the configuration

This commit is contained in:
2024-12-18 09:19:27 +08:00
parent 3f1e302d6b
commit a793d7b731
3 changed files with 17 additions and 13 deletions

View File

@@ -12,6 +12,7 @@ storage:
src: _post/src src: _post/src
dst: _post/dst dst: _post/dst
type: COS type: COS
auto_pull: true
cos: cos:
appid: appid:
bucket: bucket:

View File

@@ -1,10 +1,11 @@
package config package config
type mStorage struct { type mStorage struct {
SRC string `yaml:"src"` SRC string `yaml:"src"`
DST string `yaml:"dst"` DST string `yaml:"dst"`
Type string `yaml:"type"` Type string `yaml:"type"`
COS cosConfig `yaml:"cos"` COS cosConfig `yaml:"cos"`
AutoPull bool `yaml:"auto_pull"`
} }
type cosConfig struct { type cosConfig struct {

View File

@@ -21,16 +21,18 @@ func (ma *MApp) loadMarkdownFiles() error {
markdownPath := ma.Config.Storage.SRC markdownPath := ma.Config.Storage.SRC
switch ma.Config.Storage.Type { if ma.Config.Storage.AutoPull {
case "COS": switch ma.Config.Storage.Type {
err = storage.CosLoadMarkdowns(*ma.Config, markdownPath) case "COS":
break err = storage.CosLoadMarkdowns(*ma.Config, markdownPath)
default: break
return errors.New("Unsupported storage type: " + ma.Config.Storage.Type) default:
} return errors.New("Unsupported storage type: " + ma.Config.Storage.Type)
}
if err != nil { if err != nil {
return err return err
}
} }
err = filepath.Walk(markdownPath, func(path string, info os.FileInfo, err error) error { err = filepath.Walk(markdownPath, func(path string, info os.FileInfo, err error) error {