Commit d41bfa1c authored by Link Mauve's avatar Link Mauve

Replace config.CACHE_DIR with xdg.CACHE_HOME.

parent 35495fba
......@@ -516,26 +516,6 @@ def get_image_cache():
return xdg.CACHE_HOME / 'images'
def check_create_cache_dir():
"""
create the cache directory if it doesn't exist
also create the subdirectories
"""
global CACHE_DIR
cache_home = environ.get("XDG_CACHE_HOME")
if cache_home is None or not Path(cache_home).is_absolute():
cache_home = path.join(environ.get('HOME'), '.cache')
CACHE_DIR = path.join(cache_home, 'poezio')
try:
makedirs(CACHE_DIR)
makedirs(path.join(CACHE_DIR, 'avatars'))
makedirs(path.join(CACHE_DIR, 'images'))
makedirs(path.join(CACHE_DIR, 'caps'))
except OSError:
pass
def check_config():
"""
Check the config file and print results
......@@ -725,6 +705,3 @@ DATA_DIR = ''
# the global log dir
LOG_DIR = ''
# the global cache dir
CACHE_DIR = ''
......@@ -25,8 +25,9 @@ from slixmpp.util import FileSystemCache
from poezio import common
from poezio import fixes
from poezio import xdg
from poezio.common import safeJID
from poezio.config import config, options, CACHE_DIR
from poezio.config import config, options
class Connection(slixmpp.ClientXMPP):
......@@ -120,7 +121,7 @@ class Connection(slixmpp.ClientXMPP):
# Must be loaded before 0030.
self.register_plugin('xep_0115', {
'caps_node': 'https://poez.io',
'cache': FileSystemCache(CACHE_DIR, 'caps', encode=str,
'cache': FileSystemCache(xdg.CACHE_HOME, 'caps', encode=str,
decode=lambda x: DiscoInfo(ET.fromstring(x))),
})
self.register_plugin('xep_0030')
......
......@@ -31,7 +31,7 @@ from poezio import windows
from poezio.bookmarks import BookmarkList
from poezio.common import safeJID
from poezio.config import config, firstrun, CACHE_DIR
from poezio.config import config, firstrun
from poezio.contact import Contact, Resource
from poezio.daemon import Executor
from poezio.fifo import Fifo
......@@ -41,7 +41,7 @@ from poezio.roster import roster
from poezio.size_manager import SizeManager
from poezio.text_buffer import TextBuffer
from poezio.theming import get_theme
from poezio import keyboard
from poezio import keyboard, xdg
from poezio.core.completions import CompletionCore
from poezio.core.commands import CommandCore
......@@ -77,7 +77,7 @@ class Core(object):
self.bookmarks = BookmarkList()
self.debug = False
self.remote_fifo = None
self.avatar_cache = FileSystemPerJidCache(CACHE_DIR, 'avatars', binary=True)
self.avatar_cache = FileSystemPerJidCache(xdg.CACHE_HOME, 'avatars', binary=True)
# a unique buffer used to store global information
# that are displayed in almost all tabs, in an
# information window.
......
......@@ -81,7 +81,6 @@ def main():
config.create_global_config()
config.check_create_data_dir()
config.check_create_log_dir()
config.check_create_cache_dir()
config.setup_logging()
config.post_logging_setup()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment