diff --git a/config.yaml b/config.yaml index 206a294..dc46959 100644 --- a/config.yaml +++ b/config.yaml @@ -12,6 +12,7 @@ storage: src: _post/src dst: _post/dst type: COS + auto_pull: true cos: appid: bucket: diff --git a/config/mStorage.go b/config/mStorage.go index 85d1f1b..f91306c 100644 --- a/config/mStorage.go +++ b/config/mStorage.go @@ -1,10 +1,11 @@ package config type mStorage struct { - SRC string `yaml:"src"` - DST string `yaml:"dst"` - Type string `yaml:"type"` - COS cosConfig `yaml:"cos"` + SRC string `yaml:"src"` + DST string `yaml:"dst"` + Type string `yaml:"type"` + COS cosConfig `yaml:"cos"` + AutoPull bool `yaml:"auto_pull"` } type cosConfig struct { diff --git a/internal/mApp/mMarkdown.go b/internal/mApp/mMarkdown.go index 3c91f7a..7c66b13 100644 --- a/internal/mApp/mMarkdown.go +++ b/internal/mApp/mMarkdown.go @@ -21,16 +21,18 @@ func (ma *MApp) loadMarkdownFiles() error { markdownPath := ma.Config.Storage.SRC - switch ma.Config.Storage.Type { - case "COS": - err = storage.CosLoadMarkdowns(*ma.Config, markdownPath) - break - default: - return errors.New("Unsupported storage type: " + ma.Config.Storage.Type) - } + if ma.Config.Storage.AutoPull { + switch ma.Config.Storage.Type { + case "COS": + err = storage.CosLoadMarkdowns(*ma.Config, markdownPath) + break + default: + return errors.New("Unsupported storage type: " + ma.Config.Storage.Type) + } - if err != nil { - return err + if err != nil { + return err + } } err = filepath.Walk(markdownPath, func(path string, info os.FileInfo, err error) error {