Skip to content

Build your personal knowledge base with Trilium Notes

sync fixes

zadam8850de51f5e0
diff --git a/db/migrations/0173__isErased_in_entity_changes.sql b/db/migrations/0173__isErased_in_entity_changes.sql
index 714a973f7b..af10ffac45 100644
--- a/db/migrations/0173__isErased_in_entity_changes.sql
+++ b/db/migrations/0173__isErased_in_entity_changes.sql
@@ -65,3 +65,5 @@ DELETE FROM note_revision_contents WHERE noteRevisionId IN (
);
DELETE FROM note_revisions WHERE isErased = 1;
DELETE FROM notes WHERE isErased = 1;
+
+UPDATE entity_changes SET isErased = COALESCE((SELECT isErased FROM entity_changes AS sub WHERE sub.entityId = entity_changes.entityId AND sub.entityName = 'note_revisions'), 0) WHERE entityName = 'note_revision_contents';
diff --git a/src/services/note_cache/entities/attribute.js b/src/services/note_cache/entities/attribute.js
index 3b4d68ca7c..44024d35c8 100644
--- a/src/services/note_cache/entities/attribute.js
+++ b/src/services/note_cache/entities/attribute.js
@@ -55,6 +55,15 @@ class Attribute {
return this.noteCache.notes[this.value];
}
}
+
+ // for logging etc
+ get pojo() {
+ const pojo = {...this};
+
+ delete pojo.noteCache;
+
+ return pojo;
+ }
}
module.exports = Attribute;
diff --git a/src/services/note_cache/similarity.js b/src/services/note_cache/similarity.js
index d80d399e63..ddca8c3069 100644
--- a/src/services/note_cache/similarity.js
+++ b/src/services/note_cache/similarity.js
@@ -333,14 +333,18 @@ async function findSimilarNotes(noteId) {
let value = attr.value;
let factor = 1;
- if (value.startsWith('http')) {
+ if (!value) {
+ log.info(`Unexpected falsy value for attribute ${JSON.stringify(attr.pojo)}`);
+ continue;
+ }
+ else if (value.startsWith('http')) {
value = filterUrlValue(value);
// words in URLs are not that valuable
factor = 0.5;
}
- score += gatherRewards(attr.value, factor);
+ score += gatherRewards(value, factor);
}
if (candidateNote.type === baseNote.type) {
diff --git a/src/services/options_init.js b/src/services/options_init.js
index 056d30c897..cc9b2e3a45 100644
--- a/src/services/options_init.js
+++ b/src/services/options_init.js
@@ -48,7 +48,7 @@ function initNotSyncedOptions(initialized, startNotePath = 'root', opts = {}) {
optionService.createOption('theme', opts.theme || 'white', false);
optionService.createOption('syncServerHost', opts.syncServerHost || '', false);
- optionService.createOption('syncServerTimeout', '60000', false);
+ optionService.createOption('syncServerTimeout', '120000', false);
optionService.createOption('syncProxy', opts.syncProxy || '', false);
}
diff --git a/src/services/sync.js b/src/services/sync.js
index a03db6d9c2..df926c77e4 100644
--- a/src/services/sync.js
+++ b/src/services/sync.js
@@ -158,7 +158,9 @@ async function pullChanges(syncContext) {
setLastSyncedPull(entityChanges[entityChanges.length - 1].entityChange.id);
});
- log.info(`Pulled ${entityChanges.length} changes starting at entityChangeId=${lastSyncedPull} in ${pulledDate - startDate}ms and applied them in ${Date.now() - pulledDate}ms, ${outstandingPullCount} outstanding pulls`);
+ const sizeInKb = Math.round(JSON.stringify(resp).length / 1024);
+
+ log.info(`Pulled ${entityChanges.length} changes in ${sizeInKb} KB, starting at entityChangeId=${lastSyncedPull} in ${pulledDate - startDate}ms and applied them in ${Date.now() - pulledDate}ms, ${outstandingPullCount} outstanding pulls`);
}
if (atLeastOnePullApplied) {
diff --git a/src/services/sync_options.js b/src/services/sync_options.js
index 6c0e19359c..a63b895143 100644
--- a/src/services/sync_options.js
+++ b/src/services/sync_options.js
@@ -23,6 +23,6 @@ module.exports = {
// and we need to override it with config from config.ini
return !!syncServerHost && syncServerHost !== 'disabled';
},
- getSyncTimeout: () => parseInt(get('syncServerTimeout')) || 60000,
+ getSyncTimeout: () => parseInt(get('syncServerTimeout')) || 120000,
getSyncProxy: () => get('syncProxy')
};