Remove IndexedDB files after removing IndexedDB database

This commit is contained in:
Scott Nonnenberg 2018-11-01 16:40:19 -07:00
parent 486932048c
commit fb670ad6b9
4 changed files with 27 additions and 4 deletions

View file

@ -14,6 +14,7 @@ module.exports = {
initialize,
close,
removeDB,
removeIndexedDBFiles,
createOrUpdateGroup,
getGroupById,
@ -453,6 +454,7 @@ async function updateSchema(instance) {
let db;
let filePath;
let indexedDBPath;
async function initialize({ configDir, key }) {
if (db) {
@ -466,10 +468,13 @@ async function initialize({ configDir, key }) {
throw new Error('initialize: key` is required!');
}
indexedDBPath = path.join(configDir, 'IndexedDB');
const dbDir = path.join(configDir, 'sql');
mkdirp.sync(dbDir);
filePath = path.join(dbDir, 'db.sqlite');
const sqlInstance = await openDatabase(filePath);
const promisified = promisify(sqlInstance);
@ -502,6 +507,18 @@ async function removeDB() {
rimraf.sync(filePath);
}
async function removeIndexedDBFiles() {
if (!indexedDBPath) {
throw new Error(
'removeIndexedDBFiles: Need to initialize and set indexedDBPath first!'
);
}
const pattern = path.join(indexedDBPath, '*.leveldb');
rimraf.sync(pattern);
indexedDBPath = null;
}
const GROUPS_TABLE = 'groups';
async function createOrUpdateGroup(data) {
return createOrUpdate(GROUPS_TABLE, data);

View file

@ -297,6 +297,7 @@
await mandatoryMessageUpgrade({ upgradeMessageSchema });
await migrateAllToSQLCipher({ writeNewAttachmentData, Views });
await removeDatabase();
await window.Signal.Data.removeIndexedDBFiles();
window.installStorage(window.newStorage);
await window.storage.fetch();

View file

@ -41,6 +41,7 @@ module.exports = {
close,
removeDB,
removeIndexedDBFiles,
createOrUpdateGroup,
getGroupById,
@ -319,6 +320,10 @@ async function removeDB() {
await channels.removeDB();
}
async function removeIndexedDBFiles() {
await channels.removeIndexedDBFiles();
}
// Groups
async function createOrUpdateGroup(data) {

View file

@ -227,7 +227,7 @@
"rule": "jQuery-load(",
"path": "js/background.js",
"line": " await ConversationController.load();",
"lineNumber": 404,
"lineNumber": 405,
"reasonCategory": "falseMatch",
"updated": "2018-10-02T21:00:44.007Z"
},
@ -235,7 +235,7 @@
"rule": "jQuery-$(",
"path": "js/background.js",
"line": " el: $('body'),",
"lineNumber": 467,
"lineNumber": 468,
"reasonCategory": "usageTrusted",
"updated": "2018-10-16T23:47:48.006Z",
"reasonDetail": "Protected from arbitrary input"
@ -244,7 +244,7 @@
"rule": "jQuery-wrap(",
"path": "js/background.js",
"line": " wrap(",
"lineNumber": 725,
"lineNumber": 726,
"reasonCategory": "falseMatch",
"updated": "2018-10-18T22:23:00.485Z"
},
@ -252,7 +252,7 @@
"rule": "jQuery-wrap(",
"path": "js/background.js",
"line": " await wrap(",
"lineNumber": 1215,
"lineNumber": 1227,
"reasonCategory": "falseMatch",
"updated": "2018-10-26T22:43:23.229Z"
},