mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix migration so that only really changed notes are updated, #1254
This commit is contained in:
parent
8313116b7f
commit
71894c34aa
@ -3,13 +3,15 @@ const repository = require('../../src/services/repository');
|
|||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
for (const note of repository.getEntities("SELECT * FROM notes WHERE type = 'text' AND isProtected = 0")) {
|
for (const note of repository.getEntities("SELECT * FROM notes WHERE type = 'text' AND isProtected = 0")) {
|
||||||
try {
|
try {
|
||||||
let content = note.getContent();
|
let origContent = note.getContent();
|
||||||
|
|
||||||
content = content
|
const newContent = origContent
|
||||||
.replace(/<h1/ig, "<h2")
|
.replace(/<h1/ig, "<h2")
|
||||||
.replace(/<\/h1/ig, "</h2");
|
.replace(/<\/h1/ig, "</h2");
|
||||||
|
|
||||||
note.setContent(content);
|
if (newContent !== origContent) {
|
||||||
|
note.setContent(newContent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log(`Changing note content for note ${note.noteId} failed with: ${e.message} ${e.stack}`);
|
console.log(`Changing note content for note ${note.noteId} failed with: ${e.message} ${e.stack}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user