Attempt to handle bogus IDB NotFoundError

pull/438/head
Thibaut Courouble 9 years ago
parent 426b4b2269
commit 11936b01ab

@ -71,7 +71,7 @@ class app.DB
try db.deleteObjectStore(name)
return
store: (doc, data, onSuccess, onError) ->
store: (doc, data, onSuccess, onError, _retry = true) ->
@db (db) =>
unless db
onError()
@ -82,8 +82,12 @@ class app.DB
@cachedDocs?[doc.slug] = doc.mtime
onSuccess()
return
txn.onerror = (event) ->
txn.onerror = (event) =>
event.preventDefault()
if txn.error.name is 'NotFoundError' and _retry
@migrate()
@store(doc, data, onSuccess, onError, false)
else
onError(event)
return
@ -96,7 +100,7 @@ class app.DB
return
return
unstore: (doc, onSuccess, onError) ->
unstore: (doc, onSuccess, onError, _retry = true) ->
@db (db) =>
unless db
onError()
@ -109,6 +113,10 @@ class app.DB
return
txn.onerror = (event) ->
event.preventDefault()
if txn.error.name is 'NotFoundError' and _retry
@migrate()
@unstore(doc, onSuccess, onError, false)
else
onError(event)
return

Loading…
Cancel
Save