aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-12-25 21:14:20 +0200
committerRiccardo Spagni <ric@spagni.net>2017-12-25 21:14:20 +0200
commit2ef299f2a978966d644ed31d8cefb040e84dde54 (patch)
tree9dadc54361339895348d4e1a88da569e70b4c524 /src/wallet/wallet2.cpp
parentMerge pull request #2890 (diff)
parentwallet2: don't write a .new file when not needed (diff)
downloadmonero-2ef299f2a978966d644ed31d8cefb040e84dde54.tar.xz
Merge pull request #2891
3f24e901 wallet2: don't write a .new file when not needed (moneromooo-monero)
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r--src/wallet/wallet2.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index c5b366064..96fcf33f2 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -3504,14 +3504,6 @@ void wallet2::store_to(const std::string &path, const epee::wipeable_string &pas
const std::string old_keys_file = m_keys_file;
const std::string old_address_file = m_wallet_file + ".address.txt";
- // save to new file
- std::ofstream ostr;
- ostr.open(new_file, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
- binary_archive<true> oar(ostr);
- bool success = ::serialization::serialize(oar, cache_file_data);
- ostr.close();
- THROW_WALLET_EXCEPTION_IF(!success || !ostr.good(), error::file_save_error, new_file);
-
// save keys to the new file
// if we here, main wallet file is saved and we only need to save keys and address files
if (!same_file) {
@@ -3538,6 +3530,14 @@ void wallet2::store_to(const std::string &path, const epee::wipeable_string &pas
LOG_ERROR("error removing file: " << old_address_file);
}
} else {
+ // save to new file
+ std::ofstream ostr;
+ ostr.open(new_file, std::ios_base::binary | std::ios_base::out | std::ios_base::trunc);
+ binary_archive<true> oar(ostr);
+ bool success = ::serialization::serialize(oar, cache_file_data);
+ ostr.close();
+ THROW_WALLET_EXCEPTION_IF(!success || !ostr.good(), error::file_save_error, new_file);
+
// here we have "*.new" file, we need to rename it to be without ".new"
std::error_code e = tools::replace_file(new_file, m_wallet_file);
THROW_WALLET_EXCEPTION_IF(e, error::file_save_error, m_wallet_file, e);