From 0d6caf5bb47f19320a3a1ee37462ea4b21b3d4ae Mon Sep 17 00:00:00 2001 From: ZikkeyLS Date: Wed, 5 Jun 2024 00:12:11 +0300 Subject: [PATCH] Update FileDatabase.cpp --- .../database_drivers/FileDatabase.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/skymp5-server/cpp/server_guest_lib/database_drivers/FileDatabase.cpp b/skymp5-server/cpp/server_guest_lib/database_drivers/FileDatabase.cpp index 5d69a5dd60..2a0a309ad1 100644 --- a/skymp5-server/cpp/server_guest_lib/database_drivers/FileDatabase.cpp +++ b/skymp5-server/cpp/server_guest_lib/database_drivers/FileDatabase.cpp @@ -32,6 +32,15 @@ size_t FileDatabase::Upsert(const std::vector& changeForms) f << MpChangeForm::ToJson(changeForm).dump(2); } + if (!f.is_open()) { + pImpl->logger->error("Unable to open file {}", filePath.string()); + } else if (!f) { + pImpl->logger->error("Unknown error while writing file {}", + filePath.string()); + } else { + ++nUpserted; + } + if (!f.fail()) { f.close(); @@ -43,15 +52,6 @@ size_t FileDatabase::Upsert(const std::vector& changeForms) errorCode.message()); } } - - if (!f.is_open()) { - pImpl->logger->error("Unable to open file {}", filePath.string()); - } else if (!f) { - pImpl->logger->error("Unknown error while writing file {}", - filePath.string()); - } else { - ++nUpserted; - } } return nUpserted;