added missing sync check hashes

This commit is contained in:
azivner 2018-03-31 23:19:54 -04:00
parent 87e415992c
commit ab2f28ceef
3 changed files with 26 additions and 11 deletions

View File

@ -83,16 +83,36 @@ async function getHashes() {
FROM images FROM images
ORDER BY imageId`)), 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(` labels: getHash(await sql.getRows(`
SELECT SELECT
labelId, labelId,
noteId noteId,
name, name,
value value,
dateModified, dateModified,
dateCreated dateCreated
FROM labels 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(); const elapseTimeMs = new Date().getTime() - startTime.getTime();

View File

@ -12,7 +12,6 @@ if (!fs.existsSync(TRILIUM_DATA_DIR)) {
const DOCUMENT_PATH = TRILIUM_DATA_DIR + "/document.db"; const DOCUMENT_PATH = TRILIUM_DATA_DIR + "/document.db";
const BACKUP_DIR = TRILIUM_DATA_DIR + "/backup"; const BACKUP_DIR = TRILIUM_DATA_DIR + "/backup";
const LOG_DIR = TRILIUM_DATA_DIR + "/log"; const LOG_DIR = TRILIUM_DATA_DIR + "/log";
const EXPORT_DIR = TRILIUM_DATA_DIR + "/export";
const ANONYMIZED_DB_DIR = TRILIUM_DATA_DIR + "/anonymized-db"; const ANONYMIZED_DB_DIR = TRILIUM_DATA_DIR + "/anonymized-db";
module.exports = { module.exports = {

View File

@ -4,6 +4,7 @@ const sql = require('./sql');
const utils = require('./utils'); const utils = require('./utils');
const sync_table = require('./sync_table'); const sync_table = require('./sync_table');
const repository = require('./repository'); const repository = require('./repository');
const Label = require('../entities/label');
const BUILTIN_LABELS = [ const BUILTIN_LABELS = [
'frontend_startup', 'frontend_startup',
@ -61,22 +62,17 @@ async function createLabel(noteId, name, value = "") {
value = ""; value = "";
} }
const now = utils.nowDate();
const labelId = utils.newLabelId(); const labelId = utils.newLabelId();
const position = 1 + await sql.getValue(`SELECT COALESCE(MAX(position), 0) FROM labels WHERE noteId = ?`, [noteId]); 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, labelId: labelId,
noteId: noteId, noteId: noteId,
name: name, name: name,
value: value, value: value,
position: position, position: position,
dateModified: now,
dateCreated: now,
isDeleted: false isDeleted: false
}); })).save();
await sync_table.addLabelSync(labelId);
} }
module.exports = { module.exports = {