mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-02-17 11:45:50 +00:00
Bugfix - files where not being stored reliably.
Some crashes were also happening.
This commit is contained in:
parent
e2122277ee
commit
01be1a94e5
3 changed files with 30 additions and 7 deletions
|
@ -87,9 +87,21 @@ namespace mchlib {
|
|||
bool operator== ( const FileRecordData& parOther ) const;
|
||||
#endif
|
||||
|
||||
boost::string_ref path ( void ) const { return boost::string_ref(abs_path).substr(path_offset); }
|
||||
boost::string_ref mime_type ( void ) const { return boost::string_ref(mime_full.get()).substr(mime_type_offset, mime_type_length); }
|
||||
boost::string_ref mime_charset ( void ) const { return boost::string_ref(mime_full.get()).substr(mime_charset_offset, mime_charset_length); }
|
||||
boost::string_ref path ( void ) const {
|
||||
assert(abs_path.data());
|
||||
return boost::string_ref(abs_path).substr(path_offset);
|
||||
}
|
||||
|
||||
boost::string_ref mime_type ( void ) const {
|
||||
assert(mime_full.get().data());
|
||||
return boost::string_ref(mime_full.get()).substr(mime_type_offset, mime_type_length);
|
||||
}
|
||||
|
||||
boost::string_ref mime_charset ( void ) const {
|
||||
assert(mime_full.get().data());
|
||||
return boost::string_ref(mime_full.get()).substr(mime_charset_offset, mime_charset_length);
|
||||
}
|
||||
|
||||
void set_mime_parts ( boost::string_ref parType, boost::string_ref parCharset ) {
|
||||
const auto& mime = mime_full.get();
|
||||
{
|
||||
|
|
|
@ -182,8 +182,13 @@ namespace dindb {
|
|||
"file_count", lexical_cast<std::string>(parData.size())
|
||||
);
|
||||
|
||||
for (auto z = base_file_id; z < data_size + 1; ++z) {
|
||||
#if !defined(NDEBUG)
|
||||
std::size_t inserted_count = 0;
|
||||
#endif
|
||||
for (auto z = base_file_id; z < base_file_id + data_size; ++z) {
|
||||
const std::string file_key = PROGRAM_NAME ":file:" + lexical_cast<std::string>(z);
|
||||
assert(z >= base_file_id);
|
||||
assert(static_cast<std::size_t>(z - base_file_id) < parData.size());
|
||||
const auto& file_data = parData[z - base_file_id];
|
||||
const std::string hash = tiger_to_string(file_data.hash);
|
||||
batch.hmset(
|
||||
|
@ -205,7 +210,11 @@ namespace dindb {
|
|||
PROGRAM_NAME ":hash:" + hash,
|
||||
lexical_cast<std::string>(z)
|
||||
);
|
||||
#if !defined(NDEBUG)
|
||||
++inserted_count;
|
||||
#endif
|
||||
}
|
||||
assert(inserted_count == parData.size());
|
||||
|
||||
batch.throw_if_failed();
|
||||
}
|
||||
|
@ -219,10 +228,11 @@ namespace dindb {
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
const auto result_id = std::move(*hash_reply);
|
||||
auto set_key_and_file_item = redis::range_as<FileRecordDataWithGroup>(m_redis.hscan(result_id));
|
||||
const auto file_key = PROGRAM_NAME ":file:" + *hash_reply;
|
||||
auto set_key_and_file_item = redis::range_as<FileRecordDataWithGroup>(m_redis.hscan(file_key));
|
||||
parItem = std::move(set_key_and_file_item.second);
|
||||
const std::string group_key = std::move(set_key_and_file_item.first);
|
||||
assert(parItem.hash == parHash);
|
||||
const std::string group_key = PROGRAM_NAME ":set:" + set_key_and_file_item.first;
|
||||
|
||||
auto scan_range = m_redis.hscan(group_key);
|
||||
if (empty(scan_range)) {
|
||||
|
|
|
@ -142,6 +142,7 @@ namespace redis {
|
|||
assert(parArgc >= 1);
|
||||
assert(parArgv);
|
||||
assert(parLengths); //This /could/ be null, but I don't see why it should
|
||||
assert(m_local_data);
|
||||
|
||||
const auto pending_futures = m_local_data->pending_futures.fetch_add(1);
|
||||
auto* data = new HiredisCallbackData(m_local_data->pending_futures, m_local_data->free_cmd_slot);
|
||||
|
|
Loading…
Add table
Reference in a new issue