Some changes
This commit is contained in:
parent
d4d6978d5f
commit
d465b0a4be
@ -325,7 +325,7 @@ void read_bindings(YAML::Node& root, const std::deque<std::shared_ptr<EntryBindi
|
||||
inline string apply_comments(stringstream &in, map<string, deque<string>>& comments);
|
||||
std::deque<std::shared_ptr<EntryBinding>> create_local_bindings(int& version, std::string& license);
|
||||
|
||||
#define CURRENT_CONFIG_VERSION 13
|
||||
#define CURRENT_CONFIG_VERSION 14
|
||||
vector<string> config::parseConfig(const std::string& path) {
|
||||
//FIXME test for premium!
|
||||
vector<string> errors;
|
||||
@ -406,7 +406,16 @@ vector<string> config::parseConfig(const std::string& path) {
|
||||
|
||||
nodes_key = YAML::Node(YAML::NodeType::Undefined);
|
||||
}
|
||||
default:
|
||||
case 13:
|
||||
{
|
||||
auto nodes_key = resolveNode(config, "binding.query.host").back();
|
||||
if(nodes_key.IsDefined() && nodes_key.as<string>() == "0.0.0.0")
|
||||
nodes_key = nodes_key.as<string>() + ",[::]";
|
||||
auto node_ft = resolveNode(config, "binding.file.host").back();
|
||||
if(node_ft.IsDefined() && node_ft.as<string>() == "0.0.0.0")
|
||||
node_ft = node_ft.as<string>() + ",[::]";
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
config["version"] = CURRENT_CONFIG_VERSION;
|
||||
|
@ -297,6 +297,29 @@ bool Conversation::initialize(std::string& error) {
|
||||
});
|
||||
LOG_SQL_CMD(result);
|
||||
|
||||
/* find duplicates and remove them */
|
||||
{
|
||||
map<uint64_t, shared_ptr<db::MessageBlock>> blocks;
|
||||
for(auto& block : this->message_blocks) {
|
||||
auto& entry = blocks[block->block_offset];
|
||||
if(entry) {
|
||||
debugMessage(ref_server->getServerId(), "[Conversations][{}] Found duplicated block at index {}. Using newest block and dropping old one.", this->_channel_id, block->block_offset);
|
||||
if(entry->begin_timestamp < block->begin_timestamp) {
|
||||
entry->flag_invalid = true;
|
||||
this->db_save_block(entry);
|
||||
entry = block;
|
||||
} else {
|
||||
block->flag_invalid = true;
|
||||
this->db_save_block(block);
|
||||
}
|
||||
} else
|
||||
entry = block;
|
||||
}
|
||||
|
||||
/* lets remove the invalid blocks */
|
||||
this->message_blocks.erase(std::find_if(this->message_blocks.begin(), this->message_blocks.end(), [](const shared_ptr<db::MessageBlock>& block) { return block->flag_invalid; }), this->message_blocks.end());
|
||||
}
|
||||
|
||||
/* lets find the last block */
|
||||
if(!this->message_blocks.empty()) {
|
||||
debugMessage(ref_server->getServerId(), "[Conversations][{}] Loaded {} blocks. Trying to find last block.", this->_channel_id, this->message_blocks.size());
|
||||
@ -518,8 +541,9 @@ bool Conversation::load_message_block_header(const std::shared_ptr<ts::server::c
|
||||
return true;
|
||||
|
||||
auto block_header = make_unique<fio::BlockHeader>();
|
||||
if(this->fread(&*block_header, sizeof(*block_header), block->block_offset, true) != sizeof(*block_header)) {
|
||||
error = "failed to read block header";
|
||||
auto read = this->fread(&*block_header, sizeof(*block_header), block->block_offset, true);
|
||||
if(read != sizeof(*block_header)) {
|
||||
error = "failed to read block header (read " + to_string(read) + " out of " + to_string(sizeof(*block_header)) + ": " + to_string(errno) + ")";
|
||||
return false;
|
||||
}
|
||||
if(block_header->version != 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user