rafi0101 / Android-Room-Database-Backup

Simple tool to backup and restore your room database in Android
MIT License
241 stars 19 forks source link

when restore file is incorrect, the records of DB will cleaned #26

Closed rezalaki closed 1 year ago

rezalaki commented 1 year ago

Hi sir, I really appreciate you because of your useful library, it has helped me a lot :)

But there is a problem in restoring scenario

Please imagine the following scenario

When user wants to restore (by BACKUP_FILE_LOCATION_CUSTOM_DIALOG), suddenly he chose a wrong file (for example a PDF file) what will happen now? the DB of user will be restated and all his old records in DB will be removed!! So the user will lose his old data. in this situation, the onComplete callback also shows success=true and _exitCode=EXIT_CODE_SUCCESS_

This is the problem I am facing right now...

The solution, (my suggestion)

I was wondering if there was a callback which could show the selected file name just before restore function invoke, would solve this problem. For example, if the selected file format is .PDF , I (as a developer) can check format via a simple IF and would not let restore function invoke. Just a simple IF..

Finally I hope you and your useful library, the bests and lucks :)

rafi0101 commented 1 year ago

Hello @rezalaki , Thank you very much for your inquiry. I have not thought about this scenario yet. Very good point. I will have a look at it and implement a solution for this!

rezalaki commented 1 year ago

Hi dear @rafi0101 Special thanks :)

rafi0101 commented 1 year ago

Fixed in version 1.0.0-beta12 Now you can only restore backup files