Abort initialization if user does not confirm creation of new database

Fixes #489

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
Thomas Lauf 2022-04-18 20:36:14 +02:00
parent 8ba588dc24
commit 7c316b2ae1
3 changed files with 13 additions and 5 deletions

View file

@ -98,3 +98,4 @@ Thanks to the following, who submitted detailed bug reports and excellent sugges
sclee15
varac
xerus2000
Rafael Oliveira

View file

@ -1,3 +1,5 @@
- #489 First execution creates database regardless of confirmation response
(thanks to Rafael Oliveira)
- #403 Remove incorrect output stating that an empty interval was recorded
(thanks to xeruf)
- #408 Update documentation of hint `:all`

View file

@ -169,12 +169,17 @@ void initializeDataJournalAndRules (
// If dbLocation does not exist, ask whether it should be created.
bool shinyNewDatabase = false;
if (! dbLocation.exists () &&
(cli.getHint ("yes", false) ||
confirm ("Create new database in " + dbLocation._data + "?")))
if (! dbLocation.exists ())
{
dbLocation.create (0700);
shinyNewDatabase = true;
if ((cli.getHint ("yes", false) || confirm ("Create new database in " + dbLocation._data + "?")))
{
dbLocation.create (0700);
shinyNewDatabase = true;
}
else
{
throw std::string("Initial setup aborted by user");
}
}
// Create extensions subdirectory if necessary.