Skip to content

Build your personal knowledge base with Trilium Notes

sync fixes

zadam42e85aefdcc7
diff --git a/db/migrations/0190__change_to_etapi_tokens.sql b/db/migrations/0190__change_to_etapi_tokens.sql
index 0b292572d6..a9ea45fe79 100644
--- a/db/migrations/0190__change_to_etapi_tokens.sql
+++ b/db/migrations/0190__change_to_etapi_tokens.sql
@@ -7,7 +7,9 @@ CREATE TABLE IF NOT EXISTS "etapi_tokens"
utcDateModified TEXT NOT NULL,
isDeleted INT NOT NULL DEFAULT 0);
-INSERT INTO etapi_tokens (etapiTokenId, name, tokenHash, utcDateCreated, utcDateModified, isDeleted)
+INSERT INTO etapi_tokens (etapiTokenId, name, tokenHash, utcDateCreated, utcDateModified, isDeleted)
SELECT apiTokenId, 'Trilium Sender', token, utcDateCreated, utcDateCreated, isDeleted FROM api_tokens;
DROP TABLE api_tokens;
+
+UPDATE entity_changes SET entityName = 'etapi_tokens' WHERE entityName = 'api_tokens';
diff --git a/db/schema.sql b/db/schema.sql
index 356b0ef90c..d3bf07a785 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -16,6 +16,7 @@ CREATE TABLE IF NOT EXISTS "etapi_tokens"
name TEXT NOT NULL,
tokenHash TEXT NOT NULL,
utcDateCreated TEXT NOT NULL,
+ utcDateModified TEXT NOT NULL,
isDeleted INT NOT NULL DEFAULT 0);
CREATE TABLE IF NOT EXISTS "branches" (
`branchId` TEXT NOT NULL,
diff --git a/src/services/content_hash.js b/src/services/content_hash.js
index 787db3be58..90ff248b1a 100644
--- a/src/services/content_hash.js
+++ b/src/services/content_hash.js
@@ -47,8 +47,8 @@ function checkContentHashes(otherHashes) {
const failedChecks = [];
for (const entityName in entityHashes) {
- const thisSectorHashes = entityHashes[entityName];
- const otherSectorHashes = otherHashes[entityName];
+ const thisSectorHashes = entityHashes[entityName] || {};
+ const otherSectorHashes = otherHashes[entityName] || {};
const sectors = new Set(Object.keys(thisSectorHashes).concat(Object.keys(otherSectorHashes)));
diff --git a/src/services/sync.js b/src/services/sync.js
index dffd5d76f5..37db176db8 100644
--- a/src/services/sync.js
+++ b/src/services/sync.js
@@ -250,11 +250,6 @@ async function checkContentHash(syncContext) {
const failedChecks = contentHashService.checkContentHashes(resp.entityHashes);
- process.exit(0);
- throw new Error("AAAA");
-
- return;
-
if (failedChecks.length > 0) {
// before requeuing sectors make sure the entity changes are correct
const consistencyChecks = require("./consistency_checks");