From d718b0b34eda84744778fa12a01d5be5f03753d3 Mon Sep 17 00:00:00 2001 From: PilzAdam Date: Tue, 13 Aug 2013 19:15:06 +0200 Subject: Dont write directly to files but rather write and copy a tmp file --- src/ban.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/ban.cpp') diff --git a/src/ban.cpp b/src/ban.cpp index 75bae746f..f9d32b605 100644 --- a/src/ban.cpp +++ b/src/ban.cpp @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include "strfnd.h" #include "log.h" +#include "filesys.h" BanManager::BanManager(const std::string &banfilepath): m_banfilepath(banfilepath), @@ -76,20 +77,20 @@ void BanManager::save() { JMutexAutoLock lock(m_mutex); infostream<<"BanManager: saving to "<::iterator i = m_ips.begin(); i != m_ips.end(); i++) { - os<first<<"|"<second<<"\n"; + ss << i->first << "|" << i->second << "\n"; } + + if(!fs::safeWriteToFile(m_banfilepath, ss.str())) { + infostream<<"BanManager: failed saving to "<