diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2021-10-17 13:02:48 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2021-10-17 13:22:37 +0200 |
commit | c369f615b0b53471a9f6d214e847bcaa1703ea5a (patch) | |
tree | 4cd88094ef159907f825098f11cadcb39bb19966 /main.go | |
parent | 81d1e95df27232afd10275a29471bc2958092d6d (diff) | |
download | feed2imap-go-c369f615b0b53471a9f6d214e847bcaa1703ea5a.tar.gz feed2imap-go-c369f615b0b53471a9f6d214e847bcaa1703ea5a.tar.bz2 feed2imap-go-c369f615b0b53471a9f6d214e847bcaa1703ea5a.zip |
Allow to specify path to the cache directly in the config file
Diffstat (limited to '')
-rw-r--r-- | main.go | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -15,17 +15,17 @@ import ( // flags var ( cfgFile string = "config.yml" - cacheFile string = "feed.cache" - printVersion bool = false - dryRun bool = false - buildCache bool = false - verbose bool = false - debug bool = false + cacheFile string + printVersion bool = false + dryRun bool = false + buildCache bool = false + verbose bool = false + debug bool = false ) func init() { flag.StringVar(&cfgFile, "f", cfgFile, "configuration file") - flag.StringVar(&cacheFile, "c", cacheFile, "cache file") + flag.StringVar(&cacheFile, "c", "", "override cache file location") flag.BoolVar(&printVersion, "version", printVersion, "print version and exit") flag.BoolVar(&dryRun, "dry-run", dryRun, "do everything short of uploading and writing the cache") flag.BoolVar(&buildCache, "build-cache", buildCache, "only (re)build the cache; useful after migration or when the cache is lost or corrupted") @@ -87,7 +87,13 @@ func run() error { return err } - err = state.LoadCache(cacheFile, buildCache) + cacheLocation := cacheFile + if cacheLocation == "" { + cacheLocation = cfg.Cache + } + log.Debugf("Using '%s' as cache location", cacheLocation) + + err = state.LoadCache(cacheLocation, buildCache) if err != nil { return err } @@ -136,7 +142,7 @@ func run() error { } if !dryRun { - if err = state.StoreCache(cacheFile); err != nil { + if err = state.StoreCache(cacheLocation); err != nil { return err } } |