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
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();

View file

@ -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 = {

View file

@ -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 = {