mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
No need to make two filesystem calls when checking version of thumbnail cache
This commit is contained in:
parent
3dcdc766ee
commit
07f988b109
@ -10,6 +10,7 @@ import re
|
|||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
from collections import OrderedDict, namedtuple
|
from collections import OrderedDict, namedtuple
|
||||||
|
from contextlib import suppress
|
||||||
from locale import localeconv
|
from locale import localeconv
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
@ -156,12 +157,8 @@ class ThumbnailCache:
|
|||||||
# Remove the cache if it isn't the current version
|
# Remove the cache if it isn't the current version
|
||||||
version_path = os.path.join(self.location, 'version')
|
version_path = os.path.join(self.location, 'version')
|
||||||
current_version = 0
|
current_version = 0
|
||||||
if os.path.exists(version_path):
|
with suppress(Exception), open(version_path) as f:
|
||||||
try:
|
current_version = int(f.read())
|
||||||
with open(version_path) as f:
|
|
||||||
current_version = int(f.read())
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
if current_version != self.version:
|
if current_version != self.version:
|
||||||
# The version number changed. Delete the cover cache. Can't delete
|
# The version number changed. Delete the cover cache. Can't delete
|
||||||
# it if it isn't there (first time). Note that this will not work
|
# it if it isn't there (first time). Note that this will not work
|
||||||
|
Loading…
x
Reference in New Issue
Block a user