diff --git a/src/services/content_hash.js b/src/services/content_hash.js index 3c99030d1..3a400a909 100644 --- a/src/services/content_hash.js +++ b/src/services/content_hash.js @@ -83,16 +83,36 @@ async function getHashes() { FROM images ORDER BY imageId`)), + note_images: getHash(await sql.getRows(` + SELECT + noteImageId, + noteId, + imageId, + isDeleted, + dateModified, + dateCreated + FROM note_images + ORDER BY noteImageId`)), + labels: getHash(await sql.getRows(` SELECT labelId, - noteId + noteId, name, - value + value, dateModified, dateCreated FROM labels - ORDER BY labelId`)) + ORDER BY labelId`)), + + api_tokens: getHash(await sql.getRows(` + SELECT + apiTokenId, + token, + dateCreated, + isDeleted + FROM api_tokens + ORDER BY apiTokenId`)) }; const elapseTimeMs = new Date().getTime() - startTime.getTime(); diff --git a/src/services/data_dir.js b/src/services/data_dir.js index d792fe064..28b3d5b3f 100644 --- a/src/services/data_dir.js +++ b/src/services/data_dir.js @@ -12,7 +12,6 @@ if (!fs.existsSync(TRILIUM_DATA_DIR)) { const DOCUMENT_PATH = TRILIUM_DATA_DIR + "/document.db"; const BACKUP_DIR = TRILIUM_DATA_DIR + "/backup"; const LOG_DIR = TRILIUM_DATA_DIR + "/log"; -const EXPORT_DIR = TRILIUM_DATA_DIR + "/export"; const ANONYMIZED_DB_DIR = TRILIUM_DATA_DIR + "/anonymized-db"; module.exports = { diff --git a/src/services/labels.js b/src/services/labels.js index 1b93acf73..661294859 100644 --- a/src/services/labels.js +++ b/src/services/labels.js @@ -4,6 +4,7 @@ const sql = require('./sql'); const utils = require('./utils'); const sync_table = require('./sync_table'); const repository = require('./repository'); +const Label = require('../entities/label'); const BUILTIN_LABELS = [ 'frontend_startup', @@ -61,22 +62,17 @@ async function createLabel(noteId, name, value = "") { value = ""; } - const now = utils.nowDate(); const labelId = utils.newLabelId(); const position = 1 + await sql.getValue(`SELECT COALESCE(MAX(position), 0) FROM labels WHERE noteId = ?`, [noteId]); - await sql.insert("labels", { + await (new Label({ labelId: labelId, noteId: noteId, name: name, value: value, position: position, - dateModified: now, - dateCreated: now, isDeleted: false - }); - - await sync_table.addLabelSync(labelId); + })).save(); } module.exports = {