Detect and recover from IndexedDB QuotaExceededError

Fixes #154
pull/165/head
Thibaut 10 years ago
parent 1b6ded90e9
commit 9dc99bd8ea

@ -132,6 +132,10 @@
@hideLoading()
return
onQuotaExceeded: ->
new app.views.Notif 'QuotaExceeded', autoHide: null
Raven.captureMessage 'QuotaExceededError'
onWindowError: (args...) ->
if @isInjectionError args...
@onInjectionError()

@ -8,7 +8,7 @@ class app.DB
db: (fn) ->
return fn() unless @useIndexedDB
@callbacks.push(fn)
@callbacks.push(fn) if fn
return if @open
try
@ -39,8 +39,15 @@ class app.DB
onOpenError: (event) =>
event?.preventDefault()
@useIndexedDB = @open = false
@runCallbacks()
@open = false
if event?.target?.error?.name is 'QuotaExceededError'
@reset()
@db()
app.onQuotaExceeded()
else
@useIndexedDB = false
@runCallbacks()
return
runCallbacks: (db) ->

@ -15,6 +15,10 @@ app.templates.notifError = ->
<a href="javascript:if(confirm('Are you sure you want to reset DevDocs?'))app.reset()">resetting the app</a>.<br>
You can also report this issue on <a href="https://github.com/Thibaut/devdocs/issues/new" target="_blank">GitHub</a>. """
app.templates.notifQuotaExceeded = ->
textNotif """ Oops, the offline database has exceeded its size limitation. """,
""" Unfortunately this quota can't be detected programmatically, and the database can't be opened while over the quota, so it had to be reset. """
app.templates.notifInvalidLocation = ->
textNotif """ DevDocs must be loaded from #{app.config.production_host} """,
""" Otherwise things are likely to break. """

Loading…
Cancel
Save