Software Update with apply the settings (Part12)

- Make backup file from downloaded image
- Restore original file, if an error occurs


Origin commit data
------------------
Branch: ni/coolstream
Commit: 48fff4f4db
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2013-01-01 (Tue, 01 Jan 2013)

Origin message was:
------------------
* Software Update with apply the settings (Part12)

- Make backup file from downloaded image
- Restore original file, if an error occurs


------------------
This commit was generated by Migit
This commit is contained in:
Michael Liebmann
2013-01-01 08:23:52 +01:00
parent a10ee73e99
commit 4dcf3f43cd

View File

@@ -130,6 +130,7 @@ bool CExtUpdate::ErrorReset(bool modus, const std::string & msg1, const std::str
bool CExtUpdate::applySettings(const std::string & filename, int mode)
{
#define ORGFILE_EXT ".org"
if(!FileHelpers)
FileHelpers = new CFileHelpers();
@@ -139,11 +140,19 @@ bool CExtUpdate::applySettings(const std::string & filename, int mode)
imgFilename = FILESYSTEM_ENCODING_TO_UTF8_STRING(filename);
DBG_TIMER_START()
// make backup file
FileHelpers->copyFile(imgFilename.c_str(), (imgFilename + ORGFILE_EXT).c_str(), 0644);
bool ret = applySettings();
DBG_TIMER_STOP("Image editing")
if (!ret) {
if (mtdRamError != "")
DisplayErrorMessage(mtdRamError.c_str());
// error, restore original file
unlink(imgFilename.c_str());
rename((imgFilename + ORGFILE_EXT).c_str(), imgFilename.c_str());
}
else {
if (mode == MODE_EXPERT) {