-
Notifications
You must be signed in to change notification settings - Fork 1.5k
(#8494) - Refreshes seq before indexeddb bulkDocs #8495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
860e550
7e7c371
8e59fcb
f1094f0
9f3d97a
71dd463
576bcc8
ce03972
0738a33
e72d9ac
26bff84
e669c42
400a7de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -314,6 +314,17 @@ export default function (api, req, opts, metadata, dbOpts, idbChanges, callback) | |
| }; | ||
| } | ||
|
|
||
| function refreshMetadataSeq() { | ||
| return new Promise(function (resolve) { | ||
| txn.objectStore(DOC_STORE).index('seq').openCursor(null, 'prev').onsuccess = function (evt) { | ||
|
||
| if (evt.target.result) { | ||
| metadata.seq = evt.target.result.key; | ||
| } | ||
| resolve(); | ||
| }; | ||
| }); | ||
| } | ||
|
|
||
| function updateSeq(i) { | ||
| if (i === lastWriteIndex) { | ||
| txn.objectStore(META_STORE).put(metadata); | ||
|
|
@@ -405,8 +416,10 @@ export default function (api, req, opts, metadata, dbOpts, idbChanges, callback) | |
| callback(null, results); | ||
| }; | ||
|
|
||
| // We would like to use promises here, but idb sucks | ||
| fetchExistingDocs(txn, docs); | ||
| return refreshMetadataSeq().then(function () { | ||
| // We would like to use promises here, but idb sucks | ||
| fetchExistingDocs(txn, docs); | ||
| }); | ||
| }); | ||
| }).catch(function (err) { | ||
| callback(err); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any chance of an error in this Promise, requiring a
reject()call?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good feedback. Thanks, I've made it more robust.