mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Nicer error message when indexedDB fails to initialize
This commit is contained in:
parent
802b1ab1e9
commit
16b5bc89df
@ -133,7 +133,10 @@ def show_recent():
|
||||
if not db.initialized:
|
||||
conditional_timeout(container.id, 5, show_recent)
|
||||
return
|
||||
db.get_recently_read_books(show_recent_stage2.bind(container.id))
|
||||
if db.is_ok:
|
||||
db.get_recently_read_books(show_recent_stage2.bind(container.id))
|
||||
else:
|
||||
print(db.initialize_error_msg)
|
||||
|
||||
|
||||
def show_user_details():
|
||||
|
@ -14,6 +14,7 @@ from book_list.router import back, open_book
|
||||
from book_list.top_bar import create_top_bar
|
||||
from book_list.ui import set_panel_handler
|
||||
from book_list.views import ALLOWED_MODES, DEFAULT_MODE
|
||||
from modals import error_dialog
|
||||
from dom import clear, ensure_id
|
||||
from utils import conditional_timeout
|
||||
|
||||
@ -122,7 +123,11 @@ def show_recent():
|
||||
if not db.initialized:
|
||||
conditional_timeout(container.id, 5, show_recent)
|
||||
return
|
||||
db.get_recently_read_books(show_recent_stage2.bind(container.id), 200)
|
||||
if db.is_ok:
|
||||
db.get_recently_read_books(show_recent_stage2.bind(container.id), 200)
|
||||
else:
|
||||
error_dialog(_('Database not initialized'),
|
||||
db.initialize_error_msg)
|
||||
|
||||
|
||||
def init(container_id):
|
||||
|
@ -44,6 +44,7 @@ class DB:
|
||||
|
||||
def __init__(self, callback, show_read_book_error):
|
||||
self.initialized = False
|
||||
self.is_ok = False
|
||||
self.initialize_error_msg = None
|
||||
self.callback = callback
|
||||
self.show_read_book_error = show_read_book_error
|
||||
@ -93,6 +94,7 @@ class DB:
|
||||
self.idb = idb
|
||||
self.supports_blobs = supports_blobs
|
||||
self.initialized = True
|
||||
self.is_ok = True
|
||||
if not supports_blobs:
|
||||
print('WARNING: browser does not support blob storage, calibre falling back to base64 encoding')
|
||||
|
||||
|
@ -15,7 +15,7 @@ from book_list.library_data import (
|
||||
from book_list.ui import show_panel
|
||||
from book_list.router import update_window_title, home
|
||||
from dom import clear
|
||||
from modals import create_simple_dialog_markup
|
||||
from modals import create_simple_dialog_markup, error_dialog
|
||||
from read_book.db import get_db
|
||||
from read_book.view import View
|
||||
from utils import debounce, human_readable
|
||||
@ -151,6 +151,9 @@ class ReadUI:
|
||||
return ans
|
||||
|
||||
def db_initialized(self):
|
||||
if not self.db.is_ok:
|
||||
error_dialog(_('Could not initialize database'), self.db.initialize_error_msg)
|
||||
return
|
||||
if self.pending_load is not None:
|
||||
pl, self.pending_load = self.pending_load, None
|
||||
if self.db.initialize_error_msg:
|
||||
|
Loading…
x
Reference in New Issue
Block a user