mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix isProtected consistency for images and files + related consistency check
This commit is contained in:
parent
ae17e4dc60
commit
a432ad7483
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "trilium",
|
||||
"version": "0.30.3-beta",
|
||||
"version": "0.30.4",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -117,7 +117,10 @@ async function saveNote() {
|
||||
}
|
||||
|
||||
note.title = $noteTitle.val();
|
||||
note.noteContent.content = getCurrentNoteContent(note);
|
||||
|
||||
if (note.noteContent != null) { // might be null for file/image
|
||||
note.noteContent.content = getCurrentNoteContent(note);
|
||||
}
|
||||
|
||||
// it's important to set the flag back to false immediatelly after retrieving title and content
|
||||
// otherwise we might overwrite another change (especially async code)
|
||||
|
@ -357,6 +357,13 @@ async function findLogicIssues() {
|
||||
|
||||
logFix(`Removed link ${linkId} because target note ${targetNoteId} is also deleted.`);
|
||||
});
|
||||
|
||||
await findIssues(`
|
||||
SELECT noteId
|
||||
FROM notes
|
||||
JOIN note_contents USING(noteId)
|
||||
WHERE notes.isDeleted = 0 AND notes.isProtected != note_contents.isProtected`,
|
||||
({noteId}) => `Note ${noteId} has inconsistent isProtected in notes and note_contents tables`);
|
||||
}
|
||||
|
||||
async function runSyncRowChecks(entityName, key) {
|
||||
|
@ -332,19 +332,21 @@ async function updateNote(noteId, noteUpdates) {
|
||||
|
||||
const noteTitleChanged = note.title !== noteUpdates.title;
|
||||
|
||||
noteUpdates.noteContent.content = await saveLinks(note, noteUpdates.noteContent.content);
|
||||
|
||||
note.title = noteUpdates.title;
|
||||
note.isProtected = noteUpdates.isProtected;
|
||||
await note.save();
|
||||
|
||||
if (note.type !== 'file' && note.type !== 'image') {
|
||||
const noteContent = await note.getNoteContent();
|
||||
const noteContent = await note.getNoteContent();
|
||||
|
||||
if (!['file', 'image'].includes(note.type)) {
|
||||
noteUpdates.noteContent.content = await saveLinks(note, noteUpdates.noteContent.content);
|
||||
|
||||
noteContent.content = noteUpdates.noteContent.content;
|
||||
noteContent.isProtected = noteUpdates.isProtected;
|
||||
await noteContent.save();
|
||||
}
|
||||
|
||||
noteContent.isProtected = noteUpdates.isProtected;
|
||||
await noteContent.save();
|
||||
|
||||
if (noteTitleChanged) {
|
||||
await triggerNoteTitleChanged(note);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user