Handle empty/corrupted IDB

pull/447/merge
Thibaut Courouble 9 years ago
parent 4ad1898902
commit 59918fdee5

@ -22,10 +22,17 @@ class app.DB
return return
onOpenSuccess: (event) => onOpenSuccess: (event) =>
try
db = event.target.result db = event.target.result
if db.objectStoreNames.length is 0
try db.close()
@reason = 'empty'
@onOpenError()
return
unless @checkedBuggyIDB unless @checkedBuggyIDB
@checkedBuggyIDB = true @checkedBuggyIDB = true
try
@idbTransaction(db, stores: $.makeArray(db.objectStoreNames)[0..1], mode: 'readwrite').abort() # https://bugs.webkit.org/show_bug.cgi?id=136937 @idbTransaction(db, stores: $.makeArray(db.objectStoreNames)[0..1], mode: 'readwrite').abort() # https://bugs.webkit.org/show_bug.cgi?id=136937
catch catch
try db.close() try db.close()

@ -25,10 +25,13 @@ app.templates.bootError = ->
app.templates.offlineError = (reason) -> app.templates.offlineError = (reason) ->
reason = switch reason reason = switch reason
when 'not_supported' when 'not_supported'
""" Unfortunately your browser either doesn't support it or does not make it available. """ """ Unfortunately your browser either doesn't support IndexedDB or does not make it available. """
when 'cant_open' when 'cant_open'
""" Although your browser appears to support it, DevDocs couldn't open the database.<br> """ Although your browser supports IndexedDB, DevDocs couldn't open the database.<br>
This could be because you're browsing in private mode and have disallowed offline storage on the domain. """ This could be because you're browsing in private mode or have disallowed offline storage on the domain. """
when 'empty'
""" Although your browser supports IndexedDB, DevDocs couldn't properly set up the database.<br>
This could be because the database is corrupted. Try <a href="#" data-behavior="reset">resetting the app</a>. """
when 'apple' when 'apple'
""" Unfortunately Safari's implementation of IndexedDB is <a href="https://bugs.webkit.org/show_bug.cgi?id=136937">badly broken</a>.<br> """ Unfortunately Safari's implementation of IndexedDB is <a href="https://bugs.webkit.org/show_bug.cgi?id=136937">badly broken</a>.<br>
This message will automatically go away when Apple fix their code. """ This message will automatically go away when Apple fix their code. """

Loading…
Cancel
Save