1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-31 02:01:13 +00:00

#835: Make cache failure non-fatal

This commit is contained in:
Vladimir Iakovlev 2018-10-18 00:35:18 +02:00
parent f06ebbf2ae
commit d226b8f258

View File

@ -3,11 +3,12 @@ import os
import pickle import pickle
import re import re
import shelve import shelve
import sys
import six import six
from decorator import decorator from decorator import decorator
from difflib import get_close_matches as difflib_get_close_matches from difflib import get_close_matches as difflib_get_close_matches
from functools import wraps from functools import wraps
from .logs import warn from .logs import warn, exception
from .conf import settings from .conf import settings
from .system import Path from .system import Path
@ -197,6 +198,13 @@ class Cache(object):
self._db = None self._db = None
def _init_db(self): def _init_db(self):
try:
self._setup_db()
except Exception:
exception("Unable to init cache", sys.exc_info())
self._db = {}
def _setup_db(self):
cache_dir = self._get_cache_dir() cache_dir = self._get_cache_dir()
cache_path = Path(cache_dir).joinpath('thefuck').as_posix() cache_path = Path(cache_dir).joinpath('thefuck').as_posix()