Skip to content

Commit

Permalink
Moving cache file to XDG_CACHE_DIR instead or XGD_CONFIG_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
mwerlen committed Mar 11, 2018
1 parent c9a6d77 commit 4c8e84b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion share/man/man1/urlwatch.1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ A list of URLs, commands and other jobs to watch
.B $XDG_CONFIG_HOME/urlwatch/hooks.py
A Python module that can implement new job types, filters and reporters
.TP
.B $XDG_CONFIG_HOME/urlwatch/cache.db
.B $XDG_CACHE_HOME/urlwatch/cache.db
A SQLite 3 database that contains the state history of jobs (for diffing)
.SH AUTHOR
Thomas Perl <thp.io/about>
Expand Down
7 changes: 6 additions & 1 deletion urlwatch
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ from appdirs import AppDirs

pkgname = 'urlwatch'
urlwatch_dir = os.path.expanduser(os.path.join('~', '.' + pkgname))
urlwatch_cache_dir = AppDirs(pkgname).user_cache_dir

if not os.path.exists(urlwatch_dir):
urlwatch_dir = AppDirs(pkgname).user_config_dir
Expand Down Expand Up @@ -86,8 +87,12 @@ def setup_logger(verbose):
if __name__ == '__main__':
config_file = os.path.join(urlwatch_dir, CONFIG_FILE)
urls_file = os.path.join(urlwatch_dir, URLS_FILE)
cache_file = os.path.join(urlwatch_dir, CACHE_FILE)
hooks_file = os.path.join(urlwatch_dir, HOOKS_FILE)
new_cache_file = os.path.join(urlwatch_cache_dir, CACHE_FILE)
old_cache_file = os.path.join(urlwatch_dir, CACHE_FILE)
cache_file = new_cache_file
if os.path.exists(old_cache_file) and not os.path.exists(new_cache_file):
cache_file = old_cache_file

command_config = CommandConfig(pkgname, urlwatch_dir, bindir, prefix,
config_file, urls_file, hooks_file, cache_file, False)
Expand Down

0 comments on commit 4c8e84b

Please sign in to comment.