Re-enable orphaned attachment cleanup
This commit is contained in:
parent
15751f3521
commit
9f920aa35b
4 changed files with 40 additions and 11 deletions
25
main.js
25
main.js
|
@ -26,7 +26,7 @@ const packageJson = require('./package.json');
|
|||
|
||||
const sql = require('./app/sql');
|
||||
const sqlChannels = require('./app/sql_channel');
|
||||
// const attachments = require('./app/attachments');
|
||||
const attachments = require('./app/attachments');
|
||||
const attachmentChannel = require('./app/attachment_channel');
|
||||
const autoUpdate = require('./app/auto_update');
|
||||
const createTrayIcon = require('./app/tray_icon');
|
||||
|
@ -618,8 +618,6 @@ app.on('ready', async () => {
|
|||
locale = loadLocale({ appLocale, logger });
|
||||
}
|
||||
|
||||
await attachmentChannel.initialize({ configDir: userDataPath });
|
||||
|
||||
let key = userConfig.get('key');
|
||||
if (!key) {
|
||||
// https://www.zetetic.net/sqlcipher/sqlcipher-api/#key
|
||||
|
@ -630,12 +628,21 @@ app.on('ready', async () => {
|
|||
await sql.initialize({ configDir: userDataPath, key });
|
||||
await sqlChannels.initialize({ userConfig });
|
||||
|
||||
// const allAttachments = await attachments.getAllAttachments(userDataPath);
|
||||
// const orphanedAttachments = await sql.removeKnownAttachments(allAttachments);
|
||||
// await attachments.deleteAll({
|
||||
// userDataPath,
|
||||
// attachments: orphanedAttachments,
|
||||
// });
|
||||
async function cleanupOrphanedAttachments() {
|
||||
const allAttachments = await attachments.getAllAttachments(userDataPath);
|
||||
const orphanedAttachments = await sql.removeKnownAttachments(
|
||||
allAttachments
|
||||
);
|
||||
await attachments.deleteAll({
|
||||
userDataPath,
|
||||
attachments: orphanedAttachments,
|
||||
});
|
||||
}
|
||||
|
||||
await attachmentChannel.initialize({
|
||||
configDir: userDataPath,
|
||||
cleanupOrphanedAttachments,
|
||||
});
|
||||
|
||||
ready = true;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue