From 7c5202dcabfa5f43b871c824f8592c59872b8dd7 Mon Sep 17 00:00:00 2001 From: sowle Date: Thu, 24 Oct 2019 08:13:37 +0300 Subject: [PATCH] wallet: fixed a bug with removing a temp file when write fails --- src/wallet/wallet2.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 880c5fc9..2bb7b9c9 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2099,8 +2099,9 @@ void wallet2::store(const std::wstring& path_to_save, const std::string& passwor r = tools::portble_serialize_obj_to_stream(*this, data_file); if (!r) { + data_file.close(); boost::filesystem::remove(tmp_file_path); // remove tmp file if smth went wrong - WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(false, "portble_serialize_obj_to_stream failed for wallet " << tmp_file_path.string()); + WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(false, "IO error while storing wallet to " << tmp_file_path.string() << " (portble_serialize_obj_to_stream failed)"); } data_file.flush();