Skip to content

Commit e80134f

Browse files
JorenarWhyNotHugo
authored andcommitted
Fix default cache database location
fixes #1296
1 parent cc68d1a commit e80134f

File tree

6 files changed

+13
-7
lines changed

6 files changed

+13
-7
lines changed

AUTHORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ Mattori Birnbaum - me [at] mattori [dot] com - https://mattori.com
5858
Pi R
5959
Alnoman Kamil - noman [at] kamil [dot] gr - https://kamil.gr
6060
Leonardo Taccari - iamleot [at] gmail [dot] com
61+
Jorenar - dev [at] jorenar [dot] com - https://jorenar.com

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ may want to subscribe to `GitHub's tag feed
1212
unreleased
1313

1414
* CHANGE the ``pkg_resources`` library is no longer required.
15+
* FIX the location of caching database to ``$XDG_CACHE_HOME``
1516

1617
0.13.0
1718
======

khal/settings/khal.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type = option('calendar', 'birthdays', 'discover', default='calendar')
7777
addresses = force_list(default='')
7878

7979
[sqlite]
80-
# khal stores its internal caching database here, by default this will be in the *$XDG_DATA_HOME/khal/khal.db* (this will most likely be *~/.local/share/khal/khal.db*).
80+
# khal stores its internal caching database here, by default this will be in the *$XDG_CACHE_HOME/khal/khal.db* (this will most likely be *~/.cache/khal/khal.db*).
8181
path = expand_db_path(default=None)
8282

8383
# It is mandatory to set (long)date-, time-, and datetimeformat options, all others options in the **[locale]** section are optional and have (sensible) defaults.

khal/settings/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ def expand_path(path: str) -> str:
113113

114114

115115
def expand_db_path(path: str) -> str:
116-
"""expands `~` as well as variable names, defaults to $XDG_DATA_HOME"""
116+
"""expands `~` as well as variable names, defaults to $XDG_CACHE_HOME"""
117117
if path is None:
118-
path = join(xdg.BaseDirectory.xdg_data_home, 'khal', 'khal.db')
118+
path = join(xdg.BaseDirectory.xdg_cache_home, 'khal', 'khal.db')
119119
return expanduser(expandvars(path))
120120

121121

tests/cli_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717

1818
class CustomCliRunner(CliRunner):
1919
def __init__(self, config_file, db=None, calendars=None,
20-
xdg_data_home=None, xdg_config_home=None, tmpdir=None, **kwargs) -> None:
20+
xdg_data_home=None, xdg_config_home=None,
21+
xdg_cache_home=None, tmpdir=None, **kwargs) -> None:
2122
self.config_file = config_file
2223
self.db = db
2324
self.calendars = calendars
2425
self.xdg_data_home = xdg_data_home
26+
self.xdg_cache_home = xdg_cache_home
2527
self.xdg_config_home = xdg_config_home
2628
self.tmpdir = tmpdir
2729

@@ -40,12 +42,14 @@ def runner(tmpdir, monkeypatch):
4042
calendar3 = tmpdir.mkdir('calendar3')
4143

4244
xdg_data_home = tmpdir.join('vdirs')
45+
xdg_cache_home = tmpdir.join('.cache')
4346
xdg_config_home = tmpdir.join('.config')
4447
config_file = xdg_config_home.join('khal').join('config')
4548

4649
# TODO create a vdir config on disk and let vdirsyncer actually read it
4750
monkeypatch.setattr('vdirsyncer.cli.config.load_config', lambda: Config())
4851
monkeypatch.setattr('xdg.BaseDirectory.xdg_data_home', str(xdg_data_home))
52+
monkeypatch.setattr('xdg.BaseDirectory.xdg_cache_home', str(xdg_cache_home))
4953
monkeypatch.setattr('xdg.BaseDirectory.xdg_config_home', str(xdg_config_home))
5054
monkeypatch.setattr('xdg.BaseDirectory.xdg_config_dirs', [str(xdg_config_home)])
5155

@@ -65,7 +69,7 @@ def inner(print_new=False, default_calendar=True, days=2, **kwargs):
6569
runner = CustomCliRunner(
6670
config_file=config_file, db=db, calendars={"one": calendar},
6771
xdg_data_home=xdg_data_home, xdg_config_home=xdg_config_home,
68-
tmpdir=tmpdir,
72+
xdg_cache_home=xdg_cache_home, tmpdir=tmpdir,
6973
)
7074
return runner
7175
return inner

tests/settings_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_simple_config(self):
4949
'color': None, 'priority': 10, 'type': 'calendar', 'addresses': [''],
5050
},
5151
},
52-
'sqlite': {'path': os.path.expanduser('~/.local/share/khal/khal.db')},
52+
'sqlite': {'path': os.path.expanduser('~/.cache/khal/khal.db')},
5353
'locale': LOCALE_BERLIN,
5454
'default': {
5555
'default_calendar': None,
@@ -89,7 +89,7 @@ def test_small(self):
8989
'work': {'path': os.path.expanduser('~/.calendars/work/'),
9090
'readonly': True, 'color': None, 'priority': 10,
9191
'type': 'calendar', 'addresses': ['[email protected]']}},
92-
'sqlite': {'path': os.path.expanduser('~/.local/share/khal/khal.db')},
92+
'sqlite': {'path': os.path.expanduser('~/.cache/khal/khal.db')},
9393
'locale': {
9494
'local_timezone': get_localzone(),
9595
'default_timezone': get_localzone(),

0 commit comments

Comments
 (0)