Migrate from IndexedDB before doing new version checks

This commit is contained in:
Scott Nonnenberg 2019-06-27 13:21:52 -07:00
parent 45f2bef8fe
commit 569acb091c
2 changed files with 37 additions and 24 deletions

View file

@ -1,4 +1,4 @@
/* global window, Whisper, textsecure */
/* global window, Whisper, textsecure, setTimeout */
const { isFunction } = require('lodash');
@ -142,12 +142,20 @@ async function migrateAllToSQLCipher({ writeNewAttachmentData, Views } = {}) {
}
async function doesDatabaseExist() {
window.log.info('Checking for the existence of IndexedDB data...');
return new Promise((resolve, reject) => {
const { id } = Whisper.Database;
const req = window.indexedDB.open(id);
let existed = true;
setTimeout(() => {
window.log.warn(
'doesDatabaseExist: Timed out attempting to check IndexedDB status'
);
return resolve(false);
}, 5000);
req.onerror = reject;
req.onsuccess = () => {
req.result.close();