db/Interface: Open() throws exception on error
This commit is contained in:
parent
6c2b532ae3
commit
f55bdf07d3
@ -214,8 +214,7 @@ glue_db_init_and_load(void)
|
|||||||
"because the database does not need it");
|
"because the database does not need it");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!instance->database->Open(error))
|
instance->database->Open();
|
||||||
FatalError(error);
|
|
||||||
|
|
||||||
if (!instance->database->IsPlugin(simple_db_plugin))
|
if (!instance->database->IsPlugin(simple_db_plugin))
|
||||||
return true;
|
return true;
|
||||||
|
@ -55,9 +55,10 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the database. Read it into memory if applicable.
|
* Open the database. Read it into memory if applicable.
|
||||||
|
*
|
||||||
|
* Throws #DatabaseError or std::runtime_error on error.
|
||||||
*/
|
*/
|
||||||
virtual bool Open(gcc_unused Error &error) {
|
virtual void Open() {
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +113,7 @@ public:
|
|||||||
const ConfigBlock &block,
|
const ConfigBlock &block,
|
||||||
Error &error);
|
Error &error);
|
||||||
|
|
||||||
virtual bool Open(Error &error) override;
|
virtual void Open() override;
|
||||||
virtual void Close() override;
|
virtual void Close() override;
|
||||||
virtual const LightSong *GetSong(const char *uri_utf8,
|
virtual const LightSong *GetSong(const char *uri_utf8,
|
||||||
Error &error) const override;
|
Error &error) const override;
|
||||||
@ -362,14 +362,12 @@ ProxyDatabase::Configure(const ConfigBlock &block, gcc_unused Error &error)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
ProxyDatabase::Open(gcc_unused Error &error)
|
ProxyDatabase::Open()
|
||||||
{
|
{
|
||||||
Connect();
|
Connect();
|
||||||
|
|
||||||
update_stamp = 0;
|
update_stamp = 0;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -184,8 +184,8 @@ SimpleDatabase::Load(Error &error)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
SimpleDatabase::Open(gcc_unused Error &error)
|
SimpleDatabase::Open()
|
||||||
{
|
{
|
||||||
assert(prefixed_light_song == nullptr);
|
assert(prefixed_light_song == nullptr);
|
||||||
|
|
||||||
@ -216,8 +216,6 @@ SimpleDatabase::Open(gcc_unused Error &error)
|
|||||||
|
|
||||||
root = Directory::NewRoot();
|
root = Directory::NewRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -459,10 +457,7 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri,
|
|||||||
name_fs.c_str()),
|
name_fs.c_str()),
|
||||||
compress);
|
compress);
|
||||||
try {
|
try {
|
||||||
if (!db->Open(error)) {
|
db->Open();
|
||||||
delete db;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
delete db;
|
delete db;
|
||||||
throw;
|
throw;
|
||||||
|
@ -107,7 +107,7 @@ public:
|
|||||||
bool Unmount(const char *uri);
|
bool Unmount(const char *uri);
|
||||||
|
|
||||||
/* virtual methods from class Database */
|
/* virtual methods from class Database */
|
||||||
virtual bool Open(Error &error) override;
|
virtual void Open() override;
|
||||||
virtual void Close() override;
|
virtual void Close() override;
|
||||||
|
|
||||||
const LightSong *GetSong(const char *uri_utf8,
|
const LightSong *GetSong(const char *uri_utf8,
|
||||||
|
@ -80,7 +80,7 @@ public:
|
|||||||
const ConfigBlock &block,
|
const ConfigBlock &block,
|
||||||
Error &error);
|
Error &error);
|
||||||
|
|
||||||
virtual bool Open(Error &error) override;
|
virtual void Open() override;
|
||||||
virtual void Close() override;
|
virtual void Close() override;
|
||||||
virtual const LightSong *GetSong(const char *uri_utf8,
|
virtual const LightSong *GetSong(const char *uri_utf8,
|
||||||
Error &error) const override;
|
Error &error) const override;
|
||||||
@ -168,8 +168,8 @@ UpnpDatabase::Configure(const ConfigBlock &, Error &)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
UpnpDatabase::Open(gcc_unused Error &error)
|
UpnpDatabase::Open()
|
||||||
{
|
{
|
||||||
UpnpClientGlobalInit(handle);
|
UpnpClientGlobalInit(handle);
|
||||||
|
|
||||||
@ -181,8 +181,6 @@ UpnpDatabase::Open(gcc_unused Error &error)
|
|||||||
UpnpClientGlobalFinish();
|
UpnpClientGlobalFinish();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -136,10 +136,7 @@ try {
|
|||||||
|
|
||||||
AtScopeExit(db) { delete db; };
|
AtScopeExit(db) { delete db; };
|
||||||
|
|
||||||
if (!db->Open(error)) {
|
db->Open();
|
||||||
cerr << error.GetMessage() << endl;
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
AtScopeExit(db) { db->Close(); };
|
AtScopeExit(db) { db->Close(); };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user