History

Detect and recover from IndexedDB QuotaExceededError

Fixes #154

Thibaut committed 11 years ago

Commit 9dc99bd1 parent 1b6ded93 files · +18 −3Browse files

Showing the changes to assets/javascripts/app (2 of 3 files). Show all

Unified · Split

2 files
  1. assets/javascripts/app/app.coffee +4 −0
  2. assets/javascripts/app/db.coffee +10 −3
assets/javascripts/app/app.coffee+4−0
@@ -132,6 +132,10 @@ · 131 unmodified lines
132132 @hideLoading()
133133 return
134134
135+ onQuotaExceeded: ->
136+ new app.views.Notif 'QuotaExceeded', autoHide: null
137+ Raven.captureMessage 'QuotaExceededError'
138+
135139 onWindowError: (args...) ->
136140 if @isInjectionError args...
137141 @onInjectionError()
assets/javascripts/app/db.coffee+10−3
@@ -8,7 +8,7 @@ class app.DB · 7 unmodified lines
88
99 db: (fn) ->
1010 return fn() unless @useIndexedDB
11− @callbacks.push(fn)
11+ @callbacks.push(fn) if fn
1212 return if @open
1313
1414 try
@@ -39,8 +39,15 @@ class app.DB · 24 unmodified lines
3939
4040 onOpenError: (event) =>
4141 event?.preventDefault()
42− @useIndexedDB = @open = false
43− @runCallbacks()
42+ @open = false
43+
44+ if event?.target?.error?.name is 'QuotaExceededError'
45+ @reset()
46+ @db()
47+ app.onQuotaExceeded()
48+ else
49+ @useIndexedDB = false
50+ @runCallbacks()
4451 return
4552
4653 runCallbacks: (db) ->