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