Detect and recover from IndexedDB QuotaExceededError

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

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

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

@ -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> <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>. """ 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 = -> app.templates.notifInvalidLocation = ->
textNotif """ DevDocs must be loaded from #{app.config.production_host} """, textNotif """ DevDocs must be loaded from #{app.config.production_host} """,
""" Otherwise things are likely to break. """ """ Otherwise things are likely to break. """

Loading…
Cancel
Save