Fix allow_user_override not working for I() and also fix allow_user_override not working with different values for the same path.

This commit is contained in:
Kovid Goyal 2014-08-18 09:45:03 +05:30
parent 64d37eae40
commit 2639cc26ba

View File

@ -45,7 +45,8 @@ class PathResolver(object):
def __call__(self, path, allow_user_override=True): def __call__(self, path, allow_user_override=True):
path = path.replace(os.sep, '/') path = path.replace(os.sep, '/')
ans = self.cache.get(path, None) key = (path, allow_user_override)
ans = self.cache.get(key, None)
if ans is None: if ans is None:
for base in self.locations: for base in self.locations:
if not allow_user_override and base == self.user_path: if not allow_user_override and base == self.user_path:
@ -58,7 +59,7 @@ class PathResolver(object):
if ans is None: if ans is None:
ans = os.path.join(self.default_path, *path.split('/')) ans = os.path.join(self.default_path, *path.split('/'))
self.cache[path] = ans self.cache[key] = ans
return ans return ans
@ -73,8 +74,8 @@ def get_path(path, data=False, allow_user_override=True):
def get_image_path(path, data=False, allow_user_override=True): def get_image_path(path, data=False, allow_user_override=True):
if not path: if not path:
return get_path('images') return get_path('images', allow_user_override=allow_user_override)
return get_path('images/'+path, data=data) return get_path('images/'+path, data=data, allow_user_override=allow_user_override)
def _compile_coffeescript(name): def _compile_coffeescript(name):
from calibre.utils.serve_coffee import compile_coffeescript from calibre.utils.serve_coffee import compile_coffeescript