db/Interface: remove IsPlugin(), use dynamic_cast instead

This commit is contained in:
Max Kellermann
2018-11-19 19:19:20 +01:00
parent ed9ece5ea3
commit bda77ffc5b
5 changed files with 15 additions and 30 deletions

View File

@@ -52,10 +52,6 @@ public:
return plugin;
}
bool IsPlugin(const DatabasePlugin &other) const noexcept {
return &plugin == &other;
}
/**
* Open the database. Read it into memory if applicable.
*

View File

@@ -94,11 +94,9 @@ UpdateService::CancelMount(const char *uri)
cancel_current = next.IsDefined() && next.storage == storage2;
}
Database &_db2 = *lr.directory->mounted_database;
if (_db2.IsPlugin(simple_db_plugin)) {
SimpleDatabase &db2 = static_cast<SimpleDatabase &>(_db2);
queue.Erase(db2);
cancel_current |= next.IsDefined() && next.db == &db2;
if (auto *db2 = dynamic_cast<SimpleDatabase *>(lr.directory->mounted_database)) {
queue.Erase(*db2);
cancel_current |= next.IsDefined() && next.db == db2;
}
if (cancel_current && walk != nullptr) {
@@ -190,12 +188,10 @@ UpdateService::Enqueue(const char *path, bool discard)
/* follow the mountpoint, update the mounted
database */
Database &_db2 = *lr.directory->mounted_database;
if (!_db2.IsPlugin(simple_db_plugin))
db2 = dynamic_cast<SimpleDatabase *>(lr.directory->mounted_database);
if (db2 == nullptr)
throw std::runtime_error("Cannot update this type of database");
db2 = static_cast<SimpleDatabase *>(&_db2);
if (lr.uri == nullptr) {
storage2 = storage.GetMount(path);
path = "";