From 50cadf3dac0d56ef8181d1800cc30f8dcb749141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 13 Jun 2017 10:38:39 +0200 Subject: Implement our own database ORM, and update the whole code to use it Entirely replace LiteSQL fix #3271 --- src/utils/reload.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/utils') diff --git a/src/utils/reload.cpp b/src/utils/reload.cpp index 348c5b5..fdca9bc 100644 --- a/src/utils/reload.cpp +++ b/src/utils/reload.cpp @@ -26,7 +26,7 @@ void reload_process() #ifdef USE_DATABASE try { open_database(); - } catch (const litesql::DatabaseError&) { + } catch (...) { log_warning("Re-using the previous database."); } #endif -- cgit v1.2.3 From 8d1d822edf72e2bf426a1512fb2e19ef65e97b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 14 Jun 2017 00:04:19 +0200 Subject: Explicitely close the Database before re-opening it --- src/utils/reload.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/utils') diff --git a/src/utils/reload.cpp b/src/utils/reload.cpp index fdca9bc..807a9ab 100644 --- a/src/utils/reload.cpp +++ b/src/utils/reload.cpp @@ -11,6 +11,7 @@ void open_database() #ifdef USE_DATABASE const auto db_filename = Config::get("db_name", xdg_data_path("biboumi.sqlite")); log_info("Opening database: ", db_filename); + Database::close(); Database::open(db_filename); log_info("database successfully opened."); #endif -- cgit v1.2.3 From 40db183e3753486deaa43e950fff38579c5ced6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 16 Jun 2017 09:52:40 +0200 Subject: Using OptionalBool, add RecordHistoryOptional col into IrcChannelOptions table ref #3269 --- src/utils/optional_bool.hpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/utils/optional_bool.hpp (limited to 'src/utils') diff --git a/src/utils/optional_bool.hpp b/src/utils/optional_bool.hpp new file mode 100644 index 0000000..824e76d --- /dev/null +++ b/src/utils/optional_bool.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include + +struct OptionalBool +{ + OptionalBool() = default; + + OptionalBool(bool value): + is_set(true), value(value) {} + + void set_value(bool value) + { + this->is_set = true; + this->value = value; + } + + void unset() + { + this->is_set = false; + } + + bool is_set{false}; + bool value{false}; +}; -- cgit v1.2.3 From e75d7ad8ea72044fdfd2317e03f91ba5bea06b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 16 Jun 2017 10:48:54 +0200 Subject: Add a Record History option in the Channel configuration form fix #3269 --- src/utils/optional_bool.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/utils') diff --git a/src/utils/optional_bool.hpp b/src/utils/optional_bool.hpp index 824e76d..59bbbab 100644 --- a/src/utils/optional_bool.hpp +++ b/src/utils/optional_bool.hpp @@ -20,6 +20,16 @@ struct OptionalBool this->is_set = false; } + std::string to_string() + { + if (this->is_set == false) + return "unset"; + else if (this->value) + return "true"; + else + return "false"; + } + bool is_set{false}; bool value{false}; }; -- cgit v1.2.3 From 4d55a120d8fa5564a439102ab97b43da589bf4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 21 Jun 2017 17:36:53 +0200 Subject: Re-implement correctly the handling of failure to open the database MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we can’t open it at startup, we exit. If we can’t open it on reload, we keep the previously-opened database. This way, we’re assured to always have a valid and open database available. --- src/utils/reload.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/utils') diff --git a/src/utils/reload.cpp b/src/utils/reload.cpp index 807a9ab..fdca9bc 100644 --- a/src/utils/reload.cpp +++ b/src/utils/reload.cpp @@ -11,7 +11,6 @@ void open_database() #ifdef USE_DATABASE const auto db_filename = Config::get("db_name", xdg_data_path("biboumi.sqlite")); log_info("Opening database: ", db_filename); - Database::close(); Database::open(db_filename); log_info("database successfully opened."); #endif -- cgit v1.2.3