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