Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error message on wrong db version #8895

Open
moving-bits opened this issue Aug 28, 2020 · 7 comments
Open

Show error message on wrong db version #8895

moving-bits opened this issue Aug 28, 2020 · 7 comments
Labels
Feature Request A request for a new feature/function

Comments

@moving-bits
Copy link
Member

Not sure if it's possible technically, but it would be useful:

cgeo should never crash even with an newer DB version. There should be a message saying "newer DB version in backup, can not read backup, please update cgeo version".

Originally posted by @geocachermgo in #8876 (comment)

I'll add to this: Error instead of crash should also be the case when downgrading c:geo reusing the existing database stored internally, without doing an explicit restore.

@moving-bits moving-bits added the Feature Request A request for a new feature/function label Aug 28, 2020
@eddiemuc
Copy link
Contributor

DB version can be retrieved for a DB by executing pragma user_version. My PR for #2553 contains a method for this in DataStore

@moving-bits
Copy link
Member Author

DB version can be retrieved for a DB by executing pragma user_version. My PR for #2553 contains a method for this in DataStore

It's even easier, there is a getVersion() method :-)

I'm currently creating a PR for part 1, checking DB version before trying a restore.

@eddiemuc
Copy link
Contributor

It's even easier, there is a getVersion() method :-)

Damn :-) Ok I did not know that...

@moving-bits
Copy link
Member Author

Damn :-) Ok I did not know that...

Me neither, before I stumbled upon it in the docs today :-)

@moving-bits
Copy link
Member Author

Part 1 is implemented with #8908 - Check database version before trying a database restore.

Part 2 needs to be explored yet - Check database version on startup and display a meaningful message if db version is not compatible - instead of just crashing.

@moving-bits
Copy link
Member Author

As for part 2:

  • A check "current db version <= expected db version" may work (to be explored yet),
  • but for the case "current db version > expected db version" we need to check whether it is downgradeable, but for this we need to open the database - bamm!

Thus we could only display a warning message in this case (if at all), stating that

  • there is a version mismatch,
  • and we try to downgrade the database,
  • and inform the user what to do (or where to look) if it fails.

Alternatively we need to find a way to open the database without automatic upgrading/downgrading, to be able to read the extension table only, and then do the "is downgradeable" check.

@eddiemuc
Copy link
Contributor

Alternatively we need to find a way to open the database without automatic upgrading/downgrading, to be able to read the extension table only, and then do the "is downgradeable" check.

Is is possible/feasible to simply first open the db with SQLiteDatabase.openDatabase (without using any DBHelper and version-upgrade/downgrade), then perform the necessary checks and continue only afterwards with the "full" DBHelper?
Granted, this adds startup time for opening the DB, can't tell whether this is a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request A request for a new feature/function
Projects
None yet
Development

No branches or pull requests

2 participants