From 4dcf3f43cd47d70a3d61a89aa0ea2cadc4004bca Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Tue, 1 Jan 2013 08:23:52 +0100 Subject: [PATCH] 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: https://github.com/neutrino-images/ni-neutrino/commit/48fff4f4dbbe92fec564a39dc95e2338fcd00399 Author: Michael Liebmann 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 --- src/gui/ext_update.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/ext_update.cpp b/src/gui/ext_update.cpp index 7e4d430e4..c883a7060 100644 --- a/src/gui/ext_update.cpp +++ b/src/gui/ext_update.cpp @@ -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) {