aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md4
-rw-r--r--config.yml.example2
-rw-r--r--main.go24
-rw-r--r--pkg/config/config.go2
4 files changed, 23 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c8e97d2..4dadb85 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,9 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
+### Added
+- Location of the cache can now be specified in the config.yml. Rationale: Easier way of dealing with multiple configurations, as each also requires a distinct cache.
+
## [1.1.1] - 2021-07-24
### Fixed
- Correctly log out from the imap server and do not harshly disconnect.
+
## [1.1.0] - 2021-06-18
### Fixed
- Do not try to download already embedded images (i.e. `data:image/`).
diff --git a/config.yml.example b/config.yml.example
index 747ccc2..1f2c159 100644
--- a/config.yml.example
+++ b/config.yml.example
@@ -21,6 +21,8 @@ target:
# target: imap://test%40example.com:passw0rd@mail.example.com:143/INBOX/Feeds
## Global Options
+# Location of the cache. Can also be overwritten on the command line.
+cache: "feed.cache"
# Timeout in seconds for fetching feeds.
timeout: 30
# Maximum number of failures allowed before they are reported in normal mode.
diff --git a/main.go b/main.go
index 95eee73..d2d0a3c 100644
--- a/main.go
+++ b/main.go
@@ -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
}
}
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 231ce9e..32f4a71 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -17,6 +17,7 @@ type Map map[string]interface{}
// GlobalOptions are not feed specific
type GlobalOptions struct {
+ Cache string `yaml:"cache"`
Timeout int `yaml:"timeout"`
DefaultEmail string `yaml:"default-email"`
Target Url `yaml:"target"`
@@ -26,6 +27,7 @@ type GlobalOptions struct {
}
var DefaultGlobalOptions = GlobalOptions{
+ Cache: "feed.cache",
Timeout: 30,
MaxFailures: 10,
DefaultEmail: username() + "@" + Hostname(),