diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-06-16 16:13:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-06-16 16:13:50 +0300 |
commit | c8c48c694acc69f949f95b99355ac2cdae66ab31 (patch) | |
tree | b8f2686e1d429717a29da4bc9eefd7cad8233255 /src | |
parent | f229df2c856cfb54ac49ef2f938384278f72b4dd (diff) | |
download | manaplus-c8c48c694acc69f949f95b99355ac2cdae66ab31.tar.gz manaplus-c8c48c694acc69f949f95b99355ac2cdae66ab31.tar.bz2 manaplus-c8c48c694acc69f949f95b99355ac2cdae66ab31.tar.xz manaplus-c8c48c694acc69f949f95b99355ac2cdae66ab31.zip |
Check is disk ok before backuping configs.
And if test copy error happend, terminate application with error message.
Diffstat (limited to 'src')
-rw-r--r-- | src/configmanager.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/configmanager.cpp b/src/configmanager.cpp index cd0185627..6105cc752 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -146,6 +146,30 @@ void ConfigManager::initConfiguration() void ConfigManager::backupConfig(const std::string &name) { + const std::string fileName3 = std::string(settings.configDir).append( + "/").append(name); + StringVect arr; + if (Files::loadTextFileLocal(fileName3, arr) == true) + { + if (arr.size() == 0) + return; + + arr.clear(); + const std::string tmpName = std::string( + settings.configDir).append( + "/").append( + name).append( + ".tmp"); + Files::copyFile(fileName3, tmpName); + if (Files::loadTextFileLocal(tmpName, arr) == false || + arr.size() == 0) + { + logger->safeError("Error backuping configs. " + "Probably no free space on disk."); + } + arr.clear(); + } + const std::string confName = std::string( settings.configDir).append( "/").append( @@ -159,8 +183,6 @@ void ConfigManager::backupConfig(const std::string &name) const std::string fileName2 = confName + toString(f); Files::renameFile(fileName1, fileName2); } - const std::string fileName3 = std::string(settings.configDir).append( - "/").append(name); const std::string fileName4 = confName + toString(1); Files::copyFile(fileName3, fileName4); } |