Windows: Fix error when applying hyphenation in bulk with Polish books. Fixes #1873949 [Bulk Polishing fails with 'Access Denied'](https://bugs.launchpad.net/calibre/+bug/1873949)

This commit is contained in:
Kovid Goyal 2020-04-23 09:13:23 +05:30
parent 3d6c8dd286
commit 0d033196fc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -13,6 +13,7 @@ from io import BytesIO
from calibre.constants import cache_dir
from calibre.ptempfile import TemporaryDirectory
from calibre.utils.localization import lang_as_iso639_1
from calibre.utils.lock import ExclusiveFile
from polyglot.builtins import iteritems
from polyglot.functools import lru_cache
@ -79,10 +80,12 @@ def extract_dicts(cache_path):
def is_cache_up_to_date(cache_path):
if getattr(is_cache_up_to_date, 'updated', False):
return True
hsh = P('hyphenation/sha1sum', data=True)
hsh = P('hyphenation/sha1sum', data=True, allow_user_override=False)
try:
with open(os.path.join(cache_path, 'f', 'sha1sum'), 'rb') as f:
return f.read() == hsh
if f.read() == hsh:
is_cache_up_to_date.updated = True
return True
except EnvironmentError:
pass
return False
@ -102,6 +105,7 @@ def get_cache_path(cd):
def path_to_dictionary(dictionary_name, cache_callback=None):
cd = getattr(path_to_dictionary, 'cache_dir', None) or cache_dir()
cache_path = get_cache_path(cd)
with ExclusiveFile(os.path.join(cache_path, 'lock')):
if not is_cache_up_to_date(cache_path):
extract_dicts(cache_path)
if cache_callback is not None: