Unified · Split
| @@ -71,7 +71,7 @@ class app.DB · 70 unmodified lines | ||
| 71 | 71 | try db.deleteObjectStore(name) |
| 72 | 72 | return |
| 73 | 73 | |
| 74 | − store: (doc, data, onSuccess, onError) -> | |
| 74 | + store: (doc, data, onSuccess, onError, _retry = true) -> | |
| 75 | 75 | @db (db) => |
| 76 | 76 | unless db |
| 77 | 77 | onError() |
| @@ -82,9 +82,13 @@ class app.DB · 4 unmodified lines | ||
| 82 | 82 | @cachedDocs?[doc.slug] = doc.mtime |
| 83 | 83 | onSuccess() |
| 84 | 84 | return |
| 85 | − txn.onerror = (event) -> | |
| 85 | + txn.onerror = (event) => | |
| 86 | 86 | event.preventDefault() |
| 87 | − onError(event) | |
| 87 | + if txn.error.name is 'NotFoundError' and _retry | |
| 88 | + @migrate() | |
| 89 | + @store(doc, data, onSuccess, onError, false) | |
| 90 | + else | |
| 91 | + onError(event) | |
| 88 | 92 | return |
| 89 | 93 | |
| 90 | 94 | store = txn.objectStore(doc.slug) |
| @@ -96,7 +100,7 @@ class app.DB · 5 unmodified lines | ||
| 96 | 100 | return |
| 97 | 101 | return |
| 98 | 102 | |
| 99 | − unstore: (doc, onSuccess, onError) -> | |
| 103 | + unstore: (doc, onSuccess, onError, _retry = true) -> | |
| 100 | 104 | @db (db) => |
| 101 | 105 | unless db |
| 102 | 106 | onError() |
| @@ -109,7 +113,11 @@ class app.DB · 6 unmodified lines | ||
| 109 | 113 | return |
| 110 | 114 | txn.onerror = (event) -> |
| 111 | 115 | event.preventDefault() |
| 112 | − onError(event) | |
| 116 | + if txn.error.name is 'NotFoundError' and _retry | |
| 117 | + @migrate() | |
| 118 | + @unstore(doc, onSuccess, onError, false) | |
| 119 | + else | |
| 120 | + onError(event) | |
| 113 | 121 | return |
| 114 | 122 | |
| 115 | 123 | store = txn.objectStore(doc.slug) |