CorruptedArk / did-i-take-my-meds

A Kotlin Android app to manage medications
GNU General Public License v3.0
172 stars 14 forks source link

"Back up database" failed until I tried to do it charging the device #41

Closed fjfnaranjo closed 2 years ago

fjfnaranjo commented 2 years ago

Describe the bug

In my phone, I needed to have the cable connected to be able to backup/restore the database the first time.

After that, I'm able to backup/restore properly even with the cable unplugged.

To Reproduce

Steps to reproduce the behavior:

  1. Go to main application screen
  2. Click on "Back up database" in the 3 dots menu.
  3. See error "Backup failed"
  4. Connect cable.
  5. Do miscellaneous debugging to find the problem using logcat.
  6. See line:
    01-16 10:53:14.100   738  1553 V BackupManagerConstants: getKeyValueBackupRequireCharging(...) returns true
  7. Get suspicious about it... Lurk on the related github repository...
  8. Plug the cable.
  9. Try to backup again.
  10. BAM! It worked.
  11. Get sad because I can't reproduce it anymore and think if a bug report is worth the developer time...

Expected behavior

I expected it to work the first time.

Smartphone:

Additional context

As a software developer who dealt sometimes with oddly specific bug reports I will completely understand if you drop this :P

Thanks for the app :)

CorruptedArk commented 2 years ago

I appreciate this report and the fact you went digging into logs. I'll try to fix this when I have time

johannes87 commented 2 years ago

Thanks a lot for your app. I also experienced the "Back up failed" error, and I think I found a fix that works reliably for me. I tested creating and restoring of the backup.

How I reproduced the "Back up failed" error:

Result:

I noticed that the line imageFolder.copyRecursively(File(tempFolder.path + File.separator + imageFolder.name) in MainActivity.kt / backUpResultStarter caused an exception, which says that the source file doesn't exist.

The cause of the problem seems to be that if no medications have proof images, imageFolder doesn't get created, and the back up routine expects the folder to exist, and thus fails.

I created a pull request for a fix, which creates imageFolder in MainActivity / onCreated if it does not exist: https://github.com/CorruptedArk/did-i-take-my-meds/pull/46

CorruptedArk commented 2 years ago

@johannes87 I will have to test the pull request before I approve and merge, but good work investigating and providing a fix

I still have to try and figure out what's going on with the charging thing, but this is a good catch

fjfnaranjo commented 2 years ago

I think you should consider closing this issue.

It can be specific to my device. And if you close this and someone reports it again in the future you can open it again.

Also. Johannes issue seems completely unrelated.

Having less issues open in the tracked may help you choose better what to spend you time on.

And thanks again for your work :) .

CorruptedArk commented 2 years ago

@fjfnaranjo That's fair, I think I will for now. And of course, I'm happy this app is helping people.

My time has been a lot more limited lately too. I recently got a full time job, so I've really only been able to work a little bit on this project during weekends