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