Re-enable orphaned attachment cleanup
This commit is contained in:
parent
15751f3521
commit
9f920aa35b
4 changed files with 40 additions and 11 deletions
|
@ -11,8 +11,9 @@ module.exports = {
|
|||
let initialized = false;
|
||||
|
||||
const ERASE_ATTACHMENTS_KEY = 'erase-attachments';
|
||||
const CLEANUP_ORPHANED_ATTACHMENTS_KEY = 'cleanup-orphaned-attachments';
|
||||
|
||||
async function initialize({ configDir }) {
|
||||
async function initialize({ configDir, cleanupOrphanedAttachments }) {
|
||||
if (initialized) {
|
||||
throw new Error('initialze: Already initialized!');
|
||||
}
|
||||
|
@ -29,8 +30,19 @@ async function initialize({ configDir }) {
|
|||
event.sender.send(`${ERASE_ATTACHMENTS_KEY}-done`);
|
||||
} catch (error) {
|
||||
const errorForDisplay = error && error.stack ? error.stack : error;
|
||||
console.log(`sql-erase error: ${errorForDisplay}`);
|
||||
console.log(`erase attachments error: ${errorForDisplay}`);
|
||||
event.sender.send(`${ERASE_ATTACHMENTS_KEY}-done`, error);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on(CLEANUP_ORPHANED_ATTACHMENTS_KEY, async event => {
|
||||
try {
|
||||
await cleanupOrphanedAttachments();
|
||||
event.sender.send(`${CLEANUP_ORPHANED_ATTACHMENTS_KEY}-done`);
|
||||
} catch (error) {
|
||||
const errorForDisplay = error && error.stack ? error.stack : error;
|
||||
console.log(`cleanup orphaned attachments error: ${errorForDisplay}`);
|
||||
event.sender.send(`${CLEANUP_ORPHANED_ATTACHMENTS_KEY}-done`, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue