diff options
author | Max Kellermann <max@duempel.org> | 2016-03-18 22:17:46 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2016-03-19 00:05:11 +0100 |
commit | f55bdf07d38652ba1eeab4ba4016ed5c6267d692 (patch) | |
tree | 0f626d19a43094f19cd7b2b8f3ec1515ca9e6fb3 /src/db | |
parent | 6c2b532ae3c0987ca7f5ce9a6994617959cac20e (diff) |
db/Interface: Open() throws exception on error
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/Interface.hxx | 5 | ||||
-rw-r--r-- | src/db/plugins/ProxyDatabasePlugin.cxx | 8 | ||||
-rw-r--r-- | src/db/plugins/simple/SimpleDatabasePlugin.cxx | 11 | ||||
-rw-r--r-- | src/db/plugins/simple/SimpleDatabasePlugin.hxx | 2 | ||||
-rw-r--r-- | src/db/plugins/upnp/UpnpDatabasePlugin.cxx | 8 |
5 files changed, 13 insertions, 21 deletions
diff --git a/src/db/Interface.hxx b/src/db/Interface.hxx index 852084280..e0c29395c 100644 --- a/src/db/Interface.hxx +++ b/src/db/Interface.hxx @@ -55,9 +55,10 @@ public: /** * Open the database. Read it into memory if applicable. + * + * Throws #DatabaseError or std::runtime_error on error. */ - virtual bool Open(gcc_unused Error &error) { - return true; + virtual void Open() { } /** diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index 251f39193..9a9f3e2f1 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -113,7 +113,7 @@ public: const ConfigBlock &block, Error &error); - virtual bool Open(Error &error) override; + virtual void Open() override; virtual void Close() override; virtual const LightSong *GetSong(const char *uri_utf8, Error &error) const override; @@ -362,14 +362,12 @@ ProxyDatabase::Configure(const ConfigBlock &block, gcc_unused Error &error) return true; } -bool -ProxyDatabase::Open(gcc_unused Error &error) +void +ProxyDatabase::Open() { Connect(); update_stamp = 0; - - return true; } void diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index f7bae65d8..b10f9e8ee 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -184,8 +184,8 @@ SimpleDatabase::Load(Error &error) return true; } -bool -SimpleDatabase::Open(gcc_unused Error &error) +void +SimpleDatabase::Open() { assert(prefixed_light_song == nullptr); @@ -216,8 +216,6 @@ SimpleDatabase::Open(gcc_unused Error &error) root = Directory::NewRoot(); } - - return true; } void @@ -459,10 +457,7 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri, name_fs.c_str()), compress); try { - if (!db->Open(error)) { - delete db; - return false; - } + db->Open(); } catch (...) { delete db; throw; diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.hxx b/src/db/plugins/simple/SimpleDatabasePlugin.hxx index bdb71e420..c0ecdbd13 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.hxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.hxx @@ -107,7 +107,7 @@ public: bool Unmount(const char *uri); /* virtual methods from class Database */ - virtual bool Open(Error &error) override; + virtual void Open() override; virtual void Close() override; const LightSong *GetSong(const char *uri_utf8, diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx index 6b3aa2236..2e23b206c 100644 --- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx +++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx @@ -80,7 +80,7 @@ public: const ConfigBlock &block, Error &error); - virtual bool Open(Error &error) override; + virtual void Open() override; virtual void Close() override; virtual const LightSong *GetSong(const char *uri_utf8, Error &error) const override; @@ -168,8 +168,8 @@ UpnpDatabase::Configure(const ConfigBlock &, Error &) return true; } -bool -UpnpDatabase::Open(gcc_unused Error &error) +void +UpnpDatabase::Open() { UpnpClientGlobalInit(handle); @@ -181,8 +181,6 @@ UpnpDatabase::Open(gcc_unused Error &error) UpnpClientGlobalFinish(); throw; } - - return true; } void |