Some minor snapshot updates
This commit is contained in:
parent
add439de00
commit
7d0db0dea0
@ -57,33 +57,6 @@ bool file::initialize(std::string &error, const std::string& hostnames, uint16_t
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
{
|
||||
auto query_bindings_string = this->properties()[property::SERVERINSTANCE_QUERY_HOST].as<string>();
|
||||
auto query_port = this->properties()[property::SERVERINSTANCE_QUERY_PORT].as<uint16_t>();
|
||||
auto query_bindings = net::resolve_bindings(query_bindings_string, query_port);
|
||||
deque<shared_ptr<QueryServer::Binding>> bindings;
|
||||
|
||||
for(auto& binding : query_bindings) {
|
||||
if(!get<2>(binding).empty()) {
|
||||
logError(LOG_QUERY, "Failed to resolve binding for {}: {}", get<0>(binding), get<2>(binding));
|
||||
continue;
|
||||
}
|
||||
auto entry = make_shared<QueryServer::Binding>();
|
||||
memcpy(&entry->address, &get<1>(binding), sizeof(sockaddr_storage));
|
||||
|
||||
entry->file_descriptor = -1;
|
||||
entry->event_accept = nullptr;
|
||||
bindings.push_back(entry);
|
||||
}
|
||||
|
||||
logMessage(LOG_QUERY, "Starting server on {}:{}", query_bindings_string, query_port);
|
||||
if(!queryServer->start(bindings, errorMessage)) {
|
||||
logCritical(LOG_QUERY, "Failed to start query server: {}", errorMessage);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit d26d083635929f4df73e94b3feca8287a0608612
|
||||
Subproject commit b83a798e5348cbf916b84c1ab684adbadbaf9a71
|
@ -155,10 +155,10 @@ void DatabaseHelper::deleteClient(const std::shared_ptr<VirtualServer>& server,
|
||||
state = sql::command(this->sql, "DELETE FROM `assignedGroups` WHERE `serverId` = :sid AND `cldbid` = :id", variable{":sid", serverId}, variable{":id", cldbid}).execute();
|
||||
|
||||
if(serverId == 0) {
|
||||
state = sql::command(this->sql, "DELETE FROM `clients_server` WHERE `server_id` = :sid AND `client_database_id` = :id", variable{":sid", serverId}, variable{":id", cldbid}).execute();
|
||||
} else {
|
||||
state = sql::command(this->sql, "DELETE FROM `clients_server` WHERE `client_database_id` = :id", variable{":id", cldbid}).execute();
|
||||
state = sql::command(this->sql, "DELETE FROM `clients` WHERE `client_database_id` = :id", variable{":id", cldbid}).execute();
|
||||
} else {
|
||||
state = sql::command(this->sql, "DELETE FROM `clients_server` WHERE `server_id` = :sid AND `client_database_id` = :id", variable{":sid", serverId}, variable{":id", cldbid}).execute();
|
||||
}
|
||||
|
||||
//TODO delete letters
|
||||
|
@ -111,7 +111,7 @@ bool VirtualServerManager::try_deploy_snapshot(std::string &error, ts::ServerId
|
||||
|
||||
|
||||
sql::model insert_command{this->handle->getSql(),
|
||||
"INSERT INTO `clients_server` (`server_id`, `client_unique_id`, `client_database_id`, `client_created`, `original_client_id`) SELECT :serverId, :uniqueId, `client_database_id`, :timestamp, :org_id FROM `clients` WHERE `client_unique_id` = :uniqueId;"};
|
||||
"INSERT INTO `clients_server` (`server_id`, `client_unique_id`, `client_database_id`, `client_nickname`, `client_created`, `original_client_id`) SELECT :serverId, :uniqueId, `client_database_id`, :nickname, :timestamp, :org_id FROM `clients` WHERE `client_unique_id` = :uniqueId;"};
|
||||
|
||||
insert_command.value(":serverId", target_server_id);
|
||||
|
||||
@ -119,7 +119,8 @@ bool VirtualServerManager::try_deploy_snapshot(std::string &error, ts::ServerId
|
||||
auto sqlResult = insert_command.command().values(
|
||||
variable{":uniqueId", client.unique_id},
|
||||
variable{":timestamp", std::chrono::floor<std::chrono::seconds>(client.timestamp_created.time_since_epoch()).count()},
|
||||
variable{":org_id", client.database_id}
|
||||
variable{":org_id", client.database_id},
|
||||
variable{":nickname", client.nickname}
|
||||
).execute();
|
||||
|
||||
if(!sqlResult)
|
||||
@ -154,6 +155,43 @@ bool VirtualServerManager::try_deploy_snapshot(std::string &error, ts::ServerId
|
||||
error = "failed to query client database id mappings (" + map_query_result.fmtStr() + ")";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* the descriptions */
|
||||
{
|
||||
sql::InsertQuery insert_properties_query{"properties",
|
||||
sql::Column<ServerId>("serverId"),
|
||||
sql::Column<property::PropertyType>("type"),
|
||||
sql::Column<ClientDbId>("id"),
|
||||
sql::Column<std::string>("key"),
|
||||
sql::Column<std::string>("value")
|
||||
};
|
||||
|
||||
|
||||
std::string description_property{property::describe(property::CLIENT_DESCRIPTION).name};
|
||||
for(const auto& client : snapshot_data.parsed_clients) {
|
||||
if(client.description.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto new_id = mappings.client_id.find(client.database_id);
|
||||
if(new_id == mappings.client_id.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
insert_properties_query.add_entry(
|
||||
target_server_id,
|
||||
property::PROP_TYPE_CLIENT,
|
||||
new_id->second,
|
||||
description_property,
|
||||
client.description
|
||||
);
|
||||
}
|
||||
|
||||
auto presult = insert_properties_query.execute(this->handle->getSql(), true);
|
||||
if(!presult.has_succeeded()) {
|
||||
logWarning(logging_server_id, "Failed to insert some client properties into the database ({} failed)", presult.failed_entries.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* channels */
|
||||
|
2
shared
2
shared
@ -1 +1 @@
|
||||
Subproject commit f80f629496aa20d7d4c883c4f8554bcf9271816e
|
||||
Subproject commit 4d7fabe2eae09068e0c3bb47e1b0d5d08df11e45
|
Loading…
Reference in New Issue
Block a user