From 66db6e0a4dba5614572f02e3a9b6913d2487ca8b Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Fri, 30 Mar 2012 13:44:01 +0200 Subject: binarycreator shouldn't exit with error code if it can't clean up correctly - in case there is something but ignoreErrors==true it is showing a warning message Change-Id: I9c09a310960a56432975757496984bbe36fe5028 Reviewed-by: Niels Weber Reviewed-by: Oliver Wolff --- src/libs/installer/fileutils.cpp | 19 +++++++++++++++---- tools/binarycreator/binarycreator.cpp | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp index ece86aa5d..29baf4765 100644 --- a/src/libs/installer/fileutils.cpp +++ b/src/libs/installer/fileutils.cpp @@ -234,8 +234,13 @@ void QInstaller::removeFiles(const QString &path, bool ignoreErrors) foreach (const QFileInfo &fi, entries) { if (fi.isSymLink() || fi.isFile()) { QFile f(fi.filePath()); - if (!f.remove() && !ignoreErrors) - throw Error(QObject::tr("Could not remove file %1: %2").arg(f.fileName(), f.errorString())); + if (!f.remove()) { + QString errorMessage = QObject::tr("Could not remove file %1: %2").arg(f.fileName(), f.errorString()); + if (ignoreErrors) + qWarning() << errorMessage; + else + throw Error(errorMessage); + } } } } @@ -259,8 +264,14 @@ void QInstaller::removeDirectory(const QString &path, bool ignoreErrors) removeFiles(path, ignoreErrors); foreach (const QString &dir, dirs) { errno = 0; - if (d.exists(path) && !d.rmdir(dir) && !ignoreErrors) - throw Error(QObject::tr("Could not remove folder %1: %2").arg(dir, QLatin1String(strerror(errno)))); + if (d.exists(path) && !d.rmdir(dir)) { + QString errorMessage = QObject::tr("Could not remove folder %1: %2").arg(dir, + QLatin1String(strerror(errno))); + if (ignoreErrors) + qWarning() << errorMessage; + else + throw Error(errorMessage); + } } } diff --git a/tools/binarycreator/binarycreator.cpp b/tools/binarycreator/binarycreator.cpp index aa64bf985..866b4a4a3 100644 --- a/tools/binarycreator/binarycreator.cpp +++ b/tools/binarycreator/binarycreator.cpp @@ -696,7 +696,7 @@ int main(int argc, char **argv) foreach (const QString &resource, input.binaryResources) QFile::remove(resource); } - removeDirectory(metaDir); + removeDirectory(metaDir, true); return result; } catch (const Error &e) { std::cerr << e.message() << std::endl; -- cgit v1.2.3