mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
core: fix data is not iterable error on backup restore
This commit is contained in:
committed by
Abdullah Atta
parent
930fadeae4
commit
c759350b4c
@@ -298,10 +298,19 @@ export default class Backup {
|
||||
if ("compressed" in backup && typeof decryptedData === "string")
|
||||
decryptedData = await this.db.compressor().decompress(decryptedData);
|
||||
|
||||
await this.migrateData(
|
||||
const data =
|
||||
typeof decryptedData === "string"
|
||||
? (JSON.parse(decryptedData) as BackupDataItem[])
|
||||
: Object.values(decryptedData),
|
||||
? (JSON.parse(decryptedData) as unknown)
|
||||
: Object.values(decryptedData);
|
||||
|
||||
if (!data) throw new Error("No data found.");
|
||||
|
||||
await this.migrateData(
|
||||
Array.isArray(data)
|
||||
? (data as BackupDataItem[])
|
||||
: typeof data === "object"
|
||||
? Object.values(data)
|
||||
: [],
|
||||
backup.version
|
||||
);
|
||||
}
|
||||
@@ -333,6 +342,7 @@ export default class Backup {
|
||||
}
|
||||
|
||||
private async migrateData(data: BackupDataItem[], version: number) {
|
||||
console.log(data);
|
||||
await this.db.transaction(async () => {
|
||||
for (let item of data) {
|
||||
// we do not want to restore deleted items
|
||||
|
||||
Reference in New Issue
Block a user