Delay load MR cache

This commit is contained in:
Kovid Goyal 2013-01-23 14:08:01 +05:30
parent d774d54c2f
commit 7e2ad6914d

View File

@ -21,20 +21,22 @@ from calibre.gui2.store.stores.mobileread.models import SearchFilter
from calibre.gui2.store.stores.mobileread.cache_progress_dialog import CacheProgressDialog from calibre.gui2.store.stores.mobileread.cache_progress_dialog import CacheProgressDialog
from calibre.gui2.store.stores.mobileread.cache_update_thread import CacheUpdateThread from calibre.gui2.store.stores.mobileread.cache_update_thread import CacheUpdateThread
from calibre.gui2.store.stores.mobileread.store_dialog import MobileReadStoreDialog from calibre.gui2.store.stores.mobileread.store_dialog import MobileReadStoreDialog
from calibre.utils.config import JSONConfig
class Cache(JSONConfig):
def __init__(self):
JSONConfig.__init__(self, 'mobileread_store')
self.file_path = os.path.join(cache_dir(), 'mobileread_get_books.json')
class MobileReadStore(BasicStoreConfig, StorePlugin): class MobileReadStore(BasicStoreConfig, StorePlugin):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
StorePlugin.__init__(self, *args, **kwargs) StorePlugin.__init__(self, *args, **kwargs)
self.lock = Lock() self.lock = Lock()
self.cache = Cache()
@property
def cache(self):
if not hasattr(self, '_mr_cache'):
from calibre.utils.config import JSONConfig
self._mr_cache = JSONConfig('mobileread_get_books')
self._mr_cache.file_path = os.path.join(cache_dir(),
'mobileread_get_books.json')
self._mr_cache.refresh()
return self._mr_cache
def open(self, parent=None, detail_item=None, external=False): def open(self, parent=None, detail_item=None, external=False):
url = 'http://www.mobileread.com/' url = 'http://www.mobileread.com/'