1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2025-07-18 16:44:11 +00:00

Manage read errors.

If instructed to continue on errors, store info correctly in the db.
This commit is contained in:
King_DuckZ 2015-12-10 12:13:16 +00:00
parent ed3dea8f2c
commit a0b87e6a2d
8 changed files with 81 additions and 33 deletions

View file

@ -94,6 +94,7 @@ namespace din {
}
void write_to_db (const DinDBSettings& parDB, const std::vector<FileRecordData>& parData, const SetRecordData& parSetData) {
auto bool_to_str = [](bool b) { return (b ? "true" : "false"); };
if (parData.empty()) {
return;
}
@ -111,7 +112,7 @@ namespace din {
std::ostringstream query;
query << "INSERT INTO \"files\" " <<
"(path, hash, level, group_id, is_directory, is_symlink, size, " <<
"access_time, modify_time) VALUES "
"access_time, modify_time, is_hash_valid, unreadable) VALUES "
;
const char* comma = "";
@ -121,10 +122,12 @@ namespace din {
query << '(' << conn.escaped_literal(itm.path) << ",'" << itm.hash << "',"
<< itm.level << ','
<< "currval('\"sets_id_seq\"')" << ','
<< (itm.is_directory ? "true" : "false") << ','
<< bool_to_str(itm.is_directory) << ','
<< (itm.is_symlink ? "true" : "false") << ',' << itm.size
<< ',' << '\'' << time_to_str(itm.atime, strtime_buff.get(), strtime_buff_size) << '\''
<< ',' << '\'' << time_to_str(itm.mtime, strtime_buff.get(), strtime_buff_size) << '\''
<< ',' << bool_to_str(itm.hash_valid)
<< ',' << bool_to_str(itm.unreadable)
<< ')';
comma = ",";
}