aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2015-12-24 16:46:56 +0200
committerRiccardo Spagni <ric@spagni.net>2015-12-24 16:47:01 +0200
commit514aa724f4afbd32e0c5e13b44cce2d0e714950c (patch)
tree23d44693168ec045fe459ca2c6fa58f657327956 /src/wallet
parentMerge pull request #556 (diff)
parentfix for 'failed to generate new wallet: failed to save file' error during wal... (diff)
downloadmonero-514aa724f4afbd32e0c5e13b44cce2d0e714950c.tar.xz
Merge pull request #558
a004130 fix for 'failed to generate new wallet: failed to save file' error during wallet generation (Lex Kalinkin)
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet2.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index d10529194..1210e8521 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -1293,9 +1293,11 @@ void wallet2::store()
r = epee::file_io_utils::save_string_to_file(new_file, buf);
THROW_WALLET_EXCEPTION_IF(!r, error::file_save_error, new_file);
boost::filesystem::remove(old_file); // probably does not exist
- std::error_code e = tools::replace_file(m_wallet_file, old_file);
- THROW_WALLET_EXCEPTION_IF(e, error::file_save_error, m_wallet_file, e);
- e = tools::replace_file(new_file, m_wallet_file);
+ if (boost::filesystem::exists(m_wallet_file)) {
+ std::error_code e = tools::replace_file(m_wallet_file, old_file);
+ THROW_WALLET_EXCEPTION_IF(e, error::file_save_error, m_wallet_file, e);
+ }
+ 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);
boost::filesystem::remove(old_file);
}