encryptic-team / encryptic

An encryption-focused open source note taking application
Mozilla Public License 2.0
348 stars 40 forks source link

Web-app doesn't import from laverna backup #55

Open dayfuaim opened 5 years ago

dayfuaim commented 5 years ago

When importing from laverna-backup.zip, web-app is still not importing notes. It imports my notebooks and tags. But they are empty.

Creating notes within web-app is OK.

daed commented 5 years ago

@dayfuaim Sorry it has gotten me so long to get back to you on this. Could you try it again? We've made some improvements to the import process.

The way I recommend doing it is by creating a profile, and then going into settings and clicking on "Recover from backup" in the backup tab. That should ask you for your previous password, and then it will migrate them. The migration process doesn't always refresh the window when it's done (that's something I'm working on) but if you wait until after the bar has progressed and then refresh your screen, they should be there. I've tested it a couple times with different laverna backups and it seems to work consistently so far.

dayfuaim commented 5 years ago

@daed I tried to do this. I've turned DevTools ON. So...

  1. I've created new profile.
  2. Click "Cancel" and go to "Settings" (still not changing anything).
  3. Choose "Backup" -> "Recover from backup", then choose my Laverna backup. All notes are within archive (I have verified).
  4. Then I see the "We found previous data" (Migrate) screen and click "Start".
  5. Migration started. I see processing of my notes and tags. Progress bar is very fast. Somewhere in the middle I get "Failed to migrate your old data!" answer, but migration is still in progress (I see it in Console).
  6. Migration screen stuck.
  7. After refresh I get all my notes here, but they are all empty. Although state of task lists is correct (i.e. if I did the whole list I see 100% etc.).

I did the above several times creating new profiles – the same result.

From Console output I can consider that Encryptic during migration tries to encrypt notes but fails (my notes are unencrypted) and continues.

Console output (the error part):

...
Encryption.js:315 encryption: getUserKeys()
Encryption.js:324 encryption: getUserKeys(): returning keys
Encryption.js:407 encryption: encryptModel()
Encryption.js:344 encryption: encrypt(): starting data:
Encryption.js:345 {"name":"w6610"}
Encryption.js:315 encryption: getUserKeys()
Encryption.js:324 encryption: getUserKeys(): returning keys
Encryption.js:407 encryption: encryptModel()
Encryption.js:344 encryption: encrypt(): starting data:
Encryption.js:345 {"name":"project"}
Encryption.js:315 encryption: getUserKeys()
Encryption.js:324 encryption: getUserKeys(): returning keys
Encryption.js:407 encryption: encryptModel()
Encryption.js:344 encryption: encrypt(): starting data:
Encryption.js:345 {"name":"mac"}
Encryption.js:315 encryption: getUserKeys()
Encryption.js:324 encryption: getUserKeys(): returning keys
Encryption.js:407 encryption: encryptModel()
Encryption.js:344 encryption: encrypt(): starting data:
Encryption.js:345 {"name":"knhd"}
Encryption.js:315 encryption: getUserKeys()
Encryption.js:324 encryption: getUserKeys(): returning keys
browser.js:183 lav:components/importExport/migrate/Controller error +42s TypeError: Cannot read property 'sync' of undefined
    at Tags.remove (Module.js:343)
    at Tags.saveModel (Tags.js:91)
browser.js:183 lav:workers/Delegator delegating method 'save' to workers +842ms
browser.js:183 lav:workers/Delegator sending data: +1ms {action: "execute", promiseId: 107, data: {…}}
...

Whole number is 145 notes.

Update: The above is correct also for desktop app.

timbach2 commented 5 years ago

I was caught by surprise when laverna.cc disappeared... I have a backup from January, and tried migrating here. I got the fail to migrate error, and all it got was the titles of the notes.

I tried migrating again, this time watching the console, and this is what I got:

loading file: 
Import.js:285 ArrayBuffer(168767) {}
Import.js:302 JSZip {files: {…}, comment: null, root: "", clone: ƒ}
Import.js:303 File {name: "laverna-backup (4).zip", lastModified: 1546547714652, lastModifiedDate: Thu Jan 03 2019 14:35:14 GMT-0600 (Central Standard Time), webkitRelativePath: "", size: 168767, …}
Import.js:304 files:
Import.js:307 import: import():  Old laverna backups detected.
Import.js:359 import: importCollections(): isOldBackup is true
101Import.js:364 importCollections(): ignoring [object Object]
petrkrejcik commented 5 years ago

I have similar problem with loading backup ZIP from Laverna:

  1. Create new identity in Chrome incognito
  2. Do not set any sync method
  3. Settings -> Restore backup -> ZIP file
  4. Migrating...
  5. ...I fail when 100% with JS error:
    lav:components/importExport/migrate/Controller error +24s TypeError: Cannot read property 'sync' of undefined
    at Tags.remove (Module.js:343)
    at Tags.saveModel (Tags.js:91)
    at async Tags.saveModelObject (Module.js:303)

After refresh the app shows all the notes in the sidebar but each with empty content.

When I open Chrome Dev Tools -> Application -> Storage -> IndexedDB -> lav-... -> notes all the notes have ± the same length of encryptedData although with different content. I certainly have more data in the note than the length of encryptedData.

Laverna appVersion: 0.5.0 Encryptic appVersion: 1.0.0

daed commented 5 years ago

@petrkrejcik Where did you get that appVersion from?

I'm looking at this now. I don't have any root cause identified yet.

jfsigrist commented 5 years ago

@daed

I noticed a different behaviour whether the Laverna backup was encrypted or not.

In case it wasn't encrypted, the note content is stored in the .md files instead of the .json and it's not imported to the notes-db database.

I had a fix in my own fork, I need to test it again and I'll bring it to a pull request https://github.com/jfsigrist/encryptic/commit/4feb3ac0134ecf326e3f0fbb248f1e8709da6677

petrkrejcik commented 5 years ago

@daed The Laverna appVersion is in the backup ZIP file -> notes-db -> configs.json

@jfsigrist All my backup notes are unencrypted. If it helps I can provide the backup ZIP file (containing just some public notes only).

petrkrejcik commented 5 years ago

Temporary workaround: Encrypt the notes in Laverna and import encrypted backup.

daed commented 5 years ago

We put in some more changes for the laverna import and I've cut a new release and updated the web-app. I think that the problem was specifically related to unencrypted notes. Can you try the note import again?

dayfuaim commented 5 years ago

@daed Yes, I succeeded at last to import to web-app. :) Although thru "Migration failed" window, but import was successful (unencrypted version of backup).

Next step is standalone build. :)

UPDATE: Standalone build also has succeeded to import. But only laverna-ENCRYPTED this time.

Unfortunately, I couldn't describe every single step to get this result. :( But latest steps were:

  1. "Wipe" (from Preferences)
  2. Clear every Application DB (from DevTools).
  3. Quit, Run again.
  4. Create new identity, download (previously saved) key for this identity.
  5. Preferences -> "Backup everything" -> Recover from backup -> Choose Encrypted laverna backup.
  6. Wait for ... minutes. You can watch in Console until action is stopped.
  7. Refresh.
daed commented 5 years ago

I think this is in much better shape now. There was an issue in the way models were being handled during the encryption/import stage that was potentially impacting anything being imported.

Can you give it a shot in the new release? It should also be on https://app.encryptic.org.

dayfuaim commented 5 years ago

@daed I have tried to import from Laverna old encrypted backup – success. As for me, I have no questions about it. :)

If others don't have questions too – I think we should close this issue at last. :)