@@ -40,18 +40,21 @@ void HttpServer::UpdateDatabaseInstanceIfRunning(
|
|||||||
void HttpServer::UpdateDatabaseInstance(
|
void HttpServer::UpdateDatabaseInstance(
|
||||||
shared_ptr<DatabaseInstance> context_db) {
|
shared_ptr<DatabaseInstance> context_db) {
|
||||||
const auto current_db = server_instance->LockDatabaseInstance();
|
const auto current_db = server_instance->LockDatabaseInstance();
|
||||||
if (current_db != context_db) {
|
if (current_db == context_db) {
|
||||||
auto watcher_stopped = false;
|
return;
|
||||||
if (server_instance->watcher) {
|
}
|
||||||
server_instance->watcher->Stop();
|
|
||||||
server_instance->watcher = nullptr;
|
bool has_watcher = !!server_instance->watcher;
|
||||||
watcher_stopped = true;
|
if (has_watcher) {
|
||||||
}
|
server_instance->watcher->Stop();
|
||||||
server_instance->ddb_instance = context_db;
|
server_instance->watcher = nullptr;
|
||||||
if (watcher_stopped) {
|
}
|
||||||
server_instance->watcher = make_uniq<Watcher>(*this);
|
|
||||||
server_instance->watcher->Start();
|
server_instance->ddb_instance = context_db;
|
||||||
}
|
|
||||||
|
if (has_watcher) {
|
||||||
|
server_instance->watcher = make_uniq<Watcher>(*this);
|
||||||
|
server_instance->watcher->Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,11 +67,7 @@ bool HttpServer::IsRunningOnMachine(ClientContext &context) {
|
|||||||
auto local_url = StringUtil::Format("http://localhost:%d", local_port);
|
auto local_url = StringUtil::Format("http://localhost:%d", local_port);
|
||||||
|
|
||||||
httplib::Client client(local_url);
|
httplib::Client client(local_url);
|
||||||
auto result = client.Get("/info");
|
return client.Get("/info");
|
||||||
if (result) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HttpServer::Started() {
|
bool HttpServer::Started() {
|
||||||
@@ -204,6 +203,7 @@ void HttpServer::HandleGetLocalEvents(const httplib::Request &req,
|
|||||||
if (event_dispatcher->WaitEvent(&sink)) {
|
if (event_dispatcher->WaitEvent(&sink)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sink.done();
|
sink.done();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
namespace duckdb {
|
namespace duckdb {
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
Watcher::Watcher(HttpServer &_server) : server(_server), should_run(false) {}
|
Watcher::Watcher(HttpServer &_server) : should_run(false), server(_server) {}
|
||||||
|
|
||||||
bool WasCatalogUpdated(DatabaseInstance &db, Connection &connection,
|
bool WasCatalogUpdated(DatabaseInstance &db, Connection &connection,
|
||||||
CatalogState &last_state) {
|
CatalogState &last_state) {
|
||||||
|
|||||||
Reference in New Issue
Block a user