juanro49 / autu-mandu

Autu Mandu te permite controlar ingresos y gastos de tus vehículos y mostrarlos en bonitos informes.
Apache License 2.0
13 stars 0 forks source link

Unneccesary Regex check for filename breaks Backup Restore #7

Open dursch opened 6 months ago

dursch commented 6 months ago

Hi, thanks for picking up the old CarReport App and maintaining it.

I stumpled upon an issue when I tried to restore my backup. It seems a bit odd that a backup file needs to have a very specific name to be able to restore.

I renamed my backup from "cr-2023-12-28" to "CarReport_cr-2023-12-28" because I wanted to be sure to remember which App it is for in future. This rename did let the restore fail with generic message "The selected file seems to be not usable for restore or nothing selected.".

I figured out where this comes from:

https://github.com/juanro49/autu-mandu/blame/9b4880df249aff3706591a05364bc16c8e2629a1/app/src/main/java/org/juanro/autumandu/gui/PreferencesBackupFragment.java#L468 #

This check should be completely removed, because why should the filename/path ever matter?

Thanks.

juanro49 commented 6 months ago

This check is done to check that the name matches the structure with which the backups are created https://github.com/juanro49/autu-mandu/blob/9b4880df249aff3706591a05364bc16c8e2629a1/app/src/main/java/org/juanro/autumandu/util/backup/Backup.java#L118

It's a simple name check to verify that the backup has been made with Car Report or Autu Mandu and to avoid problems when restoring by selecting a file with a different format, but as you indicate, it could be unnecessary.

dursch commented 6 months ago

It's a simple name check to verify that the backup has been made with Car Report or Autu Mandu and to avoid problems when restoring by selecting a file with a different format, but as you indicate, it could be unnecessary.

I understand that, however there are other checks and restore will fail with other errors if there is a different format. The name really hasn't anything to do with the format.

At least the error message should be reworked in my opinion.

As you are the owner, it is up to you. Just wanted to share that I stumbled upon this and name checking a file is really no good practice to verify a specific format.

juanro49 commented 6 months ago

It's a simple name check to verify that the backup has been made with Car Report or Autu Mandu and to avoid problems when restoring by selecting a file with a different format, but as you indicate, it could be unnecessary.

I understand that, however there are other checks and restore will fail with other errors if there is a different format. The name really hasn't anything to do with the format.

At least the error message should be reworked in my opinion.

As you are the owner, it is up to you. Just wanted to share that I stumbled upon this and name checking a file is really no good practice to verify a specific format.

Yes, it is something inherited from Car Report and, thanks to your suggestion, it is something I will take in consideration to modify in a future version. 😊

xelayz commented 6 months ago

I agree