Closed guihkx closed 7 months ago
Here's a quick-'n-dirty workaround for manually importing the .nbk
file on Flatpak:
*.nbk
backup file to literally this: notes.db
notes.db
to this directory: ~/.var/app/io.github.nuttyartist.notes/config/Awesomeness/
You can now run Notes normally and your notes should be back.
Thanks for the thorough investigation! Very strange behavior.
This was actually a bug in xdg-desktop-portal
:
Which has been fixed in version 1.18.2.
Luckily, Arch Linux already has this version, so I revisited this and importing the nbk
file now works as it should!
Awesome, thanks for investigating!
Steps to reproduce:
flatpak run io.github.nuttyartist.notes//stable
.nbk
fileWhat happens:
Importing fails silently (UI-wise), but this error pops up in the terminal:
I tried debugging this for a while, but I ultimately got stuck and I'm not sure what to do next.
Running the app with
strace
showed me something interesting (warning: if you run this, expect a large amount of text):Just to briefly explain that weird path (
/run/user/...
) where the.nbk
file is located:Our Flatpak app is sandboxed and doesn't have direct access to user files, so even though the user can choose any file from his computer using Qt's file chooser, that file will then be copied to a temporary location decided by xdg-desktop-portal, just so our app can access only that file.
Anyway, now analyzing the
strace
output as whole: For some reason, only the two lastopenat()
attempts specified theO_NOFOLLOW
flag, which then fail with theELOOP (Too many levels of symbolic links)
error.I tried figuring out where exactly the failure occurs, and at least this part I think I got right:
openat()
attempt is successful and happens here:https://github.com/nuttyartist/notes/blob/7466cfb726182493295838df6163e8f2fc545c2a/src/mainwindow.cpp#L2828
https://github.com/nuttyartist/notes/blob/7466cfb726182493295838df6163e8f2fc545c2a/src/dbmanager.cpp#L1747
https://github.com/nuttyartist/notes/blob/7466cfb726182493295838df6163e8f2fc545c2a/src/dbmanager.cpp#L1757
I added some logging to figure out what was the exact error given by
QSqlDatabase::open()
, and it's this one:Which appears to come from here on the Qt side:
https://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp?h=6.4.2#n762
So I thought this would be easily reproducible outside the Flatpak world if I just tried importing an
.nbk
file that was a symbolic link to another.nbk
file, but that didn't fail the import process at all. :smiling_face_with_tear:Additionally, I manually inspected the Flatpak sandbox of Notes to see if
/run/flatpak/doc/<random string>/db.nbk
is actually a symbolic link, but it's really not:Is all of this a red herring? I don't know. :shrug: