Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: fix v5.8 backups not restoring due to changed item ids (#1303)

Muhammad Alif62c04535028
diff --git a/packages/core/database/backup.js b/packages/core/database/backup.js
index d0e5ed461..58cfdc017 100644
--- a/packages/core/database/backup.js
+++ b/packages/core/database/backup.js
@@ -200,7 +200,7 @@ export default class Backup {
await this._migrator.migrate(
this._db,
collections,
- (id) => data[id],
+ (id, type) => (version < 5.8 ? data[id] : data[`${id}_${type}`]),
version,
true
);
diff --git a/packages/core/database/migrator.js b/packages/core/database/migrator.js
index 7ce47a885..33e396899 100644
--- a/packages/core/database/migrator.js
+++ b/packages/core/database/migrator.js
@@ -38,7 +38,7 @@ class Migrator {
const index = (await collection.index()) || [];
for (var i = 0; i < index.length; ++i) {
let id = index[i];
- let item = get(id);
+ let item = get(id, collection.dbCollection.collectionName);
if (!item) {
continue;
}