mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
notes with attribute "disable_versioning" set to "true" won't have history records created upon modification. This is meant for e.g. large JS libraries etc.
This commit is contained in:
parent
f439969962
commit
6f79a1c05b
@ -4,6 +4,10 @@ const sql = require('./sql');
|
|||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const sync_table = require('./sync_table');
|
const sync_table = require('./sync_table');
|
||||||
|
|
||||||
|
async function getNoteAttributeMap(noteId) {
|
||||||
|
return await sql.getMap(`SELECT name, value FROM attributes WHERE note_id = ?`, [noteId]);
|
||||||
|
}
|
||||||
|
|
||||||
async function getNoteIdWithAttribute(name, value) {
|
async function getNoteIdWithAttribute(name, value) {
|
||||||
return await sql.getFirstValue(`SELECT notes.note_id FROM notes JOIN attributes USING(note_id)
|
return await sql.getFirstValue(`SELECT notes.note_id FROM notes JOIN attributes USING(note_id)
|
||||||
WHERE notes.is_deleted = 0 AND attributes.name = ? AND attributes.value = ?`, [name, value]);
|
WHERE notes.is_deleted = 0 AND attributes.name = ? AND attributes.value = ?`, [name, value]);
|
||||||
@ -26,6 +30,7 @@ async function createAttribute(noteId, name, value = null, sourceId = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
getNoteAttributeMap,
|
||||||
getNoteIdWithAttribute,
|
getNoteIdWithAttribute,
|
||||||
createAttribute
|
createAttribute
|
||||||
};
|
};
|
@ -4,6 +4,7 @@ const utils = require('./utils');
|
|||||||
const notes = require('./notes');
|
const notes = require('./notes');
|
||||||
const data_encryption = require('./data_encryption');
|
const data_encryption = require('./data_encryption');
|
||||||
const sync_table = require('./sync_table');
|
const sync_table = require('./sync_table');
|
||||||
|
const attributes = require('./attributes');
|
||||||
|
|
||||||
async function createNewNote(parentNoteId, note, sourceId) {
|
async function createNewNote(parentNoteId, note, sourceId) {
|
||||||
const noteId = utils.newNoteId();
|
const noteId = utils.newNoteId();
|
||||||
@ -212,6 +213,8 @@ async function updateNote(noteId, newNote, dataKey, sourceId) {
|
|||||||
await encryptNote(newNote, dataKey);
|
await encryptNote(newNote, dataKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const attributesMap = await attributes.getNoteAttributeMap(noteId);
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const nowStr = utils.nowDate();
|
const nowStr = utils.nowDate();
|
||||||
|
|
||||||
@ -225,7 +228,10 @@ async function updateNote(noteId, newNote, dataKey, sourceId) {
|
|||||||
await sql.doInTransaction(async () => {
|
await sql.doInTransaction(async () => {
|
||||||
const msSinceDateCreated = now.getTime() - utils.parseDate(newNote.detail.date_created).getTime();
|
const msSinceDateCreated = now.getTime() - utils.parseDate(newNote.detail.date_created).getTime();
|
||||||
|
|
||||||
if (!existingNoteHistoryId && msSinceDateCreated >= historySnapshotTimeInterval * 1000) {
|
if (attributesMap.disable_versioning !== 'true'
|
||||||
|
&& !existingNoteHistoryId
|
||||||
|
&& msSinceDateCreated >= historySnapshotTimeInterval * 1000) {
|
||||||
|
|
||||||
await saveNoteHistory(noteId, dataKey, sourceId, nowStr);
|
await saveNoteHistory(noteId, dataKey, sourceId, nowStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user