diff --git a/BigBaseV2/src/api/remote.hpp b/BigBaseV2/src/api/remote.hpp index f682c42f..d94e8b0d 100644 --- a/BigBaseV2/src/api/remote.hpp +++ b/BigBaseV2/src/api/remote.hpp @@ -59,16 +59,21 @@ namespace big::remote http::Request req(file_url.data()); http::Response res = req.send("GET", "", headers, 30s); - std::ofstream file_ofstream(file_location, std::ios::binary | std::ios::trunc); - std::ostream_iterator file_out_iter(file_ofstream); - std::copy(res.body.begin(), res.body.end(), file_out_iter); + if (res.status == http::Response::Status::Ok) + { + std::ofstream file_ofstream(file_location, std::ios::binary | std::ios::trunc); + std::ostream_iterator file_out_iter(file_ofstream); + std::copy(res.body.begin(), res.body.end(), file_out_iter); - remote_etag = get_etag_from_headers(res.headers); + remote_etag = get_etag_from_headers(res.headers); - std::ofstream file_etag_ofstream(etag_location, std::ios::binary | std::ios::trunc); - file_etag_ofstream << remote_etag; + std::ofstream file_etag_ofstream(etag_location, std::ios::binary | std::ios::trunc); + file_etag_ofstream << remote_etag; - return true; + return true; + } + + return false; } catch (const std::exception& e) { diff --git a/BigBaseV2/src/services/gta_data/gta_data_service.cpp b/BigBaseV2/src/services/gta_data/gta_data_service.cpp index 85a118bf..0edbad71 100644 --- a/BigBaseV2/src/services/gta_data/gta_data_service.cpp +++ b/BigBaseV2/src/services/gta_data/gta_data_service.cpp @@ -43,7 +43,6 @@ namespace big g_gta_data_service = nullptr; } - const vehicle_item& gta_data_service::find_vehicle_by_hash(Hash hash) { int idx = -1; @@ -168,11 +167,8 @@ namespace big try { - std::ofstream file_ofstream(file_path, std::ios::binary | std::ios::trunc); - file_ofstream << ""; - - std::ofstream file_etag_ofstream(etag_path, std::ios::binary | std::ios::trunc); - file_etag_ofstream << ""; + std::filesystem::remove(file_to_load.get_path()); + std::filesystem::remove(file_etag.get_path()); } catch (...) { } } @@ -197,7 +193,7 @@ namespace big if (!all_vehicles.is_array()) { - throw "Invalid json format."; + throw std::exception("Invalid json format."); } m_vehicle_class_arr.clear(); @@ -250,7 +246,7 @@ namespace big if (!all_peds.is_array()) { - throw "Invalid json format."; + throw std::exception("Invalid json format."); } m_ped_type_arr.clear(); @@ -301,7 +297,7 @@ namespace big if (!all_weapons.is_array()) { - throw "Invalid json format."; + throw std::exception("Invalid json format."); } m_weapon_type_arr.clear();