Remove IndexedDB files after removing IndexedDB database

pull/27/head^2
Scott Nonnenberg 7 years ago
parent 486932048c
commit fb670ad6b9

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

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

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

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

Loading…
Cancel
Save