From 0b61b5310b715ba83ad976607158c96d6816ee4d Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Wed, 19 Dec 2012 01:19:16 +0100 Subject: [PATCH] Software Update with apply the settings (Part13) - Delete files from image, before apply settings Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/158a8ba4ceaca6587f3425d10d0a26ba188c421e Author: Michael Liebmann Date: 2012-12-19 (Wed, 19 Dec 2012) Origin message was: ------------------ * Software Update with apply the settings (Part13) - Delete files from image, before apply settings ------------------ This commit was generated by Migit --- data/settingsupdate.conf | 18 +++++++++------ src/gui/ext_update.cpp | 47 ++++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/data/settingsupdate.conf b/data/settingsupdate.conf index 45eafcac9..5234dc041 100644 --- a/data/settingsupdate.conf +++ b/data/settingsupdate.conf @@ -21,7 +21,17 @@ ## Die Verzeichnisse "/", "/dev", "/proc", "/sys", "/mnt", "/tmp" können nicht gesichert werden!! #------------------------------------------------------------------------------------------------ +#--------------------------------------------------------------------------- +## vor der Sicherung aus dem neuen Image zu löschende Dateien/Verzeichnisse, +## gekennzeichnet durch ein vorangestelltes ~ +# z.B. +# ~/share/tuxbox/neutrino/themes/Classic.theme +#--------------------------------------------------------------------------- + + +#------------- ## Sicherungen +#------------- /etc/hostname /etc/hosts /etc/network @@ -30,6 +40,7 @@ /var/etc /var/tuxbox/config + #---------------------------------------------------------------------------------------- ## von der Sicherung auszuschließende Dateien, gekennzeichnet durch ein vorangestelltes - #---------------------------------------------------------------------------------------- @@ -41,10 +52,3 @@ -/var/tuxbox/config/satellites.xml -/var/tuxbox/config/settingsupdate.conf -/var/tuxbox/config/tobackup.conf - -#---------------------------------------------------------------------------- -## nach der Sicherung aus dem neuen Image zu löschende Dateien/Verzeichnisse, -## gekennzeichnet durch ein vorangestelltes ~ -# z.B. -# ~/share/tuxbox/neutrino/themes/Classic.theme -#---------------------------------------------------------------------------- diff --git a/src/gui/ext_update.cpp b/src/gui/ext_update.cpp index c883a7060..c9094941d 100644 --- a/src/gui/ext_update.cpp +++ b/src/gui/ext_update.cpp @@ -506,6 +506,7 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) { char buf[PATH_MAX]; static struct stat FileInfo; + vector::iterator it; f1 = fopen(backupList.c_str(), "r"); if (f1 == NULL) { @@ -582,8 +583,30 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) } fclose(f1); + // read DeleteList + for(it = deleteList.begin(); it != deleteList.end(); ++it) { + line = *it; + if (lstat(line.c_str(), &FileInfo) != -1) { + if ((line.find("*") != std::string::npos) || (line.find("?") != std::string::npos)) { + // Wildcards + WRITE_UPDATE_LOG("delete file list: %s\n", line.c_str()); + deleteFileList(line.c_str()); + } + else if (S_ISREG(FileInfo.st_mode)) { + // File + WRITE_UPDATE_LOG("delete file: %s\n", line.c_str()); + unlink(line.c_str()); + } + else if (S_ISDIR(FileInfo.st_mode)){ + // Directory + WRITE_UPDATE_LOG("delete directory: %s\n", line.c_str()); + FileHelpers->removeDir(line.c_str()); + } + } + } + sync(); + // read copyList - vector::iterator it; for(it = copyList.begin(); it != copyList.end(); ++it) { line = *it; line = trim(line); @@ -628,28 +651,6 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) } } - - // read DeleteList - for(it = deleteList.begin(); it != deleteList.end(); ++it) { - line = *it; - if (lstat(line.c_str(), &FileInfo) != -1) { - if ((line.find("*") != std::string::npos) || (line.find("?") != std::string::npos)) { - // Wildcards - WRITE_UPDATE_LOG("delete file list: %s\n", line.c_str()); - deleteFileList(line.c_str()); - } - else if (S_ISREG(FileInfo.st_mode)) { - // File - WRITE_UPDATE_LOG("delete file: %s\n", line.c_str()); - unlink(line.c_str()); - } - else if (S_ISDIR(FileInfo.st_mode)){ - // Directory - WRITE_UPDATE_LOG("delete directory: %s\n", line.c_str()); - FileHelpers->removeDir(line.c_str()); - } - } - } sync(); return true; }