This commit is contained in:
Scott E. Graves 2023-12-13 14:50:19 -06:00
parent d6d4b579c9
commit 883968f53e

View File

@ -505,43 +505,38 @@ auto encrypt_provider::process_directory_entry(
api_parent = row->get_column("api_path").get_value<std::string>(); api_parent = row->get_column("api_path").get_value<std::string>();
} }
if (api_path_data.empty() || api_parent.empty()) { if (api_parent.empty()) {
if (api_parent.empty()) { api_parent = add_directory(relative_path.parent_path());
api_parent = add_directory(relative_path.parent_path()); }
}
if (api_path_data.empty()) { if (api_path_data.empty()) {
stop_type stop_requested = false; stop_type stop_requested = false;
utils::encryption::encrypting_reader reader( utils::encryption::encrypting_reader reader(
relative_path.filename().string(), dir_entry.path().string(), relative_path.filename().string(), dir_entry.path().string(),
stop_requested, cfg.encryption_token, stop_requested, cfg.encryption_token,
relative_path.parent_path().string()); relative_path.parent_path().string());
api_path = utils::path::create_api_path( api_path = utils::path::create_api_path(api_parent + "/" +
api_parent + "/" + reader.get_encrypted_file_name()); reader.get_encrypted_file_name());
auto iv_list = reader.get_iv_list(); auto iv_list = reader.get_iv_list();
json data = { json data = {
{"api_path", api_path}, {"api_path", api_path},
{"iv_list", iv_list}, {"iv_list", iv_list},
{"original_file_size", dir_entry.file_size()}, {"original_file_size", dir_entry.file_size()},
}; };
auto ins_res = auto ins_res = db::db_insert{*db_, file_table}
db::db_insert{*db_, file_table} .column_value("source_path", dir_entry.path().string())
.column_value("source_path", dir_entry.path().string()) .column_value("data", data.dump())
.column_value("data", data.dump()) .go();
.go(); // TODO handle error
// TODO handle error
ins_res = db::db_insert{*db_, source_table} ins_res = db::db_insert{*db_, source_table}
.column_value("api_path", api_path) .column_value("api_path", api_path)
.column_value("source_path", dir_entry.path().string()) .column_value("source_path", dir_entry.path().string())
.go(); .go();
// TODO handle error // TODO handle error
event_system::instance().raise<filesystem_item_added>( event_system::instance().raise<filesystem_item_added>(api_path,
api_path, api_parent, false); api_parent, false);
} else {
api_path = json::parse(api_path_data)["api_path"].get<std::string>();
}
} else { } else {
api_path = json::parse(api_path_data)["api_path"].get<std::string>(); api_path = json::parse(api_path_data)["api_path"].get<std::string>();
} }