davidhealey / waistline

Libre calorie counter app for Android. Built with Cordova.
530 stars 62 forks source link

cant export data/backup database v3.8.0 #839

Open cptwtf opened 1 week ago

cptwtf commented 1 week ago

hi, i cant export data/backup database v3.8.0 and am using a poco x3 with lineageos 14 i got a new phone and sadly when i try to backup my database i am just presented with an "Export Failed" modal error message same goes for diary export

i checked the app permissions and while storage wasnt denied, it also wasnt requested by the app

anyone got an idea how to transfer my food database?

EmilJunker commented 1 week ago

Since you are the first (and only) person to report this bug and we don't have access to your phone, the only way to find out where exactly the problem lies is for you to install a debug APK and debug it yourself with ADB and Chrome web inspect.

I have built a debug APK for Waistline that you can install next to the actual Waistline app:

app-debug.zip

If you want to do this, just download the APK and follow these steps:

  1. Enable developer mode on your phone and install ADB on your computer (see https://www.xda-developers.com/install-adb-windows-macos-linux)

  2. Connect your phone to your PC via USB. Now should show up when you run adb devices from the terminal on your PC:

image

  1. Install the debug APK on your phone. The app is called "WaistlineDev" and will coexist with the actual Waistline app without interfering with it.

  2. Open any Chromium browser and enter chrome://inspect into the address bar. You should see something like this:

Edge 2024-06-24 085153

  1. Click on "inspect" and navigate to the "Console" tab. Then press the "Backup Database" button in the app and see what logs you get in the console window.

Screenshot 2024-06-24 084852

Apologies for making this so complicated, but I don't see any other way to find out what the problem is.

cptwtf commented 1 week ago

thanks a lot for taking the time to explain, i will respond as soon as i found the time

cptwtf commented 6 days ago

i was able to export the database and diary no errors thrown in app or in the devtools console with the debug version of waistline so no idea whats causing it for me in the regular app, but again thank you for helping me out :)

Edit: ok i just realized the dev app had no data so the import is actually an empty export :/

EmilJunker commented 6 days ago

i was able to export the database and diary no errors thrown in app or in the devtools console with the debug version of waistline

Interesting. The only possible reason I could think of is that you don't have enough free storage space, so exporting a basically empty database works, but exporting the filled database doesn't 🤔 Could that be it?

cptwtf commented 6 days ago

good thinking and i just rechecked to make sure it wasnt a plain oversight like this, but while i am not sure, i think 11gb free storage space should do the job :D

EmilJunker commented 6 days ago

Yes, 11 GB should be more than enough :)

To which location/folder did the debug app write the backup file? Can you go there with a file browser app (e. g. this one is known to work) and check if there is something suspicious there maybe preventing the regular app from writing the backup?

cptwtf commented 6 days ago

okay apparently no files were written at all, it gave a success message and after that i went straight to the share backup/csv file option, which successfully shared a json and csv file but containing no content due to the dev app not using the same data but apparently both versions arent able to write the file and only the regular version noticing it it is trying to export to /Android/data/com.waist.dev/files

EmilJunker commented 6 days ago

If Waistline shows you a success message with the file path, it means the file was successfully written. What makes you think that it wasn't? What do you see when you navigate to /Android/data/ in the file browser?

cptwtf commented 6 days ago

I navigated to the folder which is in exptected structure, but unfortunately no file has been created despite the success message. I attached some screenshots so you can better follow my steps (starting from /Android/data/, used the file browser app you linked to navigate to the path):

image image image image

heres whats visible in the devtools console when triggering the export, "unfortunately" everythink looks totally fine here to me:

-1719734326315.log

cptwtf commented 6 days ago

ok so i did some digging and when i inspect devtools console the non dev Waistline app and try to backup the database i am presented with the following error: image

i then started to set some breakpoints and was able to extract my data by setting a breakpoint at line 368 of utils.js "backupDir.getFile(filename, { create: true }, (file) => {"

which seems to be the failing function and calling console.log(data) in the console, where data is given to the wrapper function as an argument image

while i got no idea whats causing it for me, at first glance i am able to "manually" extract my data this way and while i would happily provide more info if somebody wants to i am perfectly fine with this solution for myself :)

thanks for putting me on the right track how to debug this

edit: just finished and i could in fact copy the output of console.log(data) to a new file waistline_export.json and import it on my new device

EmilJunker commented 6 days ago

@cptwtf I'm glad to hear it worked out for you 🎉

There is one more thing you could check. According to this comment, the backup file may have been written to /storage/self/primary/Android/data/ instead of /storage/emulated/0/Android/data/. According to the comment, that folder can only be accessed via adb pull. So, if you want, you can check if there is something there. Otherwise you can close this issue.