mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +01:00
smaller refactorings (mostly entitization)
This commit is contained in:
@@ -4,6 +4,7 @@ const sql = require('../../services/sql');
|
||||
const utils = require('../../services/utils');
|
||||
const sync_table = require('../../services/sync_table');
|
||||
const log = require('../../services/log');
|
||||
const repository = require('../../services/repository');
|
||||
|
||||
async function cleanupSoftDeletedItems() {
|
||||
const noteIdsToDelete = await sql.getColumn("SELECT noteId FROM notes WHERE isDeleted = 1");
|
||||
@@ -33,6 +34,9 @@ async function cleanupSoftDeletedItems() {
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("branches", "branchId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("note_revisions", "noteRevisionId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("recent_notes", "branchId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("images", "imageId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("note_images", "noteImageId");
|
||||
await sync_table.cleanupSyncRowsForMissingEntities("labels", "labelId");
|
||||
|
||||
log.info("Following notes has been completely cleaned from database: " + noteIdsSql);
|
||||
}
|
||||
@@ -51,10 +55,10 @@ async function cleanupUnusedImages() {
|
||||
for (const imageId of unusedImageIds) {
|
||||
log.info(`Deleting unused image: ${imageId}`);
|
||||
|
||||
await sql.execute("UPDATE images SET isDeleted = 1, data = null, dateModified = ? WHERE imageId = ?",
|
||||
[now, imageId]);
|
||||
|
||||
await sync_table.addImageSync(imageId);
|
||||
const image = await repository.getImage(imageId);
|
||||
image.isDeleted = true;
|
||||
image.data = null;
|
||||
await image.save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user