diff options
author | kh1 <karsten.heimrich@nokia.com> | 2011-11-07 15:40:44 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@nokia.com> | 2011-11-09 14:12:05 +0100 |
commit | d72d3968450a56654452acf48c097235ac8e19a1 (patch) | |
tree | 84c35b61b44ee618a2cea2477b58cb3ad06e71a7 | |
parent | 5a5f91a97d8af4c17e264e6c1894843e740364e3 (diff) |
If there happens to be an error during fetch, reset states.
Fix some missing pieces in repo info job, we need to clear already
created tmp directories. Extend tmp dir deleter to support this...
Change-Id: Id4ff22899959e488c3346348fdf657b628a38e30
Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
Reviewed-by: Alexander Lenhardt <alexander.lenhardt@nokia.com>
-rw-r--r-- | installerbuilder/common/fileutils.cpp | 32 | ||||
-rw-r--r-- | installerbuilder/common/fileutils.h | 3 | ||||
-rw-r--r-- | installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp | 9 | ||||
-rw-r--r-- | installerbuilder/libinstaller/getrepositoriesmetainfojob.h | 2 | ||||
-rw-r--r-- | installerbuilder/libinstaller/packagemanagercore_p.cpp | 26 |
5 files changed, 52 insertions, 20 deletions
diff --git a/installerbuilder/common/fileutils.cpp b/installerbuilder/common/fileutils.cpp index fff7e9da8..725efc5c3 100644 --- a/installerbuilder/common/fileutils.cpp +++ b/installerbuilder/common/fileutils.cpp @@ -61,17 +61,7 @@ TempDirDeleter::TempDirDeleter(const QStringList &paths) TempDirDeleter::~TempDirDeleter() { - foreach (const QString &path, m_paths) { - if (!path.isEmpty()) { - try { - removeDirectory(path); - } catch (const Error &e) { - qCritical() << Q_FUNC_INFO << "Exception caught:" << e.message(); - } catch (...) { - qCritical() << Q_FUNC_INFO << "Unknown exception caught."; - } - } - } + releaseAndDeleteAll(); } QStringList TempDirDeleter::paths() const @@ -111,6 +101,26 @@ void TempDirDeleter::passAndRelease(TempDirDeleter &tdd, const QString &path) release(path); } +void TempDirDeleter::releaseAndDeleteAll() +{ + foreach (const QString &path, m_paths) + releaseAndDelete(path); +} + +void TempDirDeleter::releaseAndDelete(const QString &path) +{ + if (m_paths.contains(path)) { + try { + m_paths.remove(path); + removeDirectory(path); + } catch (const Error &e) { + qCritical() << Q_FUNC_INFO << "Exception caught:" << e.message(); + } catch (...) { + qCritical() << Q_FUNC_INFO << "Unknown exception caught."; + } + } +} + // -- read, write operations diff --git a/installerbuilder/common/fileutils.h b/installerbuilder/common/fileutils.h index 76d096460..c405f8461 100644 --- a/installerbuilder/common/fileutils.h +++ b/installerbuilder/common/fileutils.h @@ -56,6 +56,9 @@ public: void passAndReleaseAll(TempDirDeleter &tdd); void passAndRelease(TempDirDeleter &tdd, const QString &path); + void releaseAndDeleteAll(); + void releaseAndDelete(const QString &path); + private: Q_DISABLE_COPY(TempDirDeleter) QSet<QString> m_paths; diff --git a/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp b/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp index 94670a512..24a9ef794 100644 --- a/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp +++ b/installerbuilder/libinstaller/getrepositoriesmetainfojob.cpp @@ -97,13 +97,20 @@ void GetRepositoriesMetaInfoJob::setSilentRetries(int retries) m_silentRetries = retries; } -void GetRepositoriesMetaInfoJob::resetState() +void GetRepositoriesMetaInfoJob::reset() { m_canceled = false; + m_silentRetries = 3; m_errorString.clear(); m_haveIgnoredError = false; + m_repositories.clear(); + m_tmpRepositories.clear(); + m_tempDirDeleter.releaseAndDeleteAll(); + m_repositoryByTemporaryDirectory.clear(); + setError(KDJob::NoError); + setCapabilities(Cancelable); setErrorString(QLatin1String("")); } diff --git a/installerbuilder/libinstaller/getrepositoriesmetainfojob.h b/installerbuilder/libinstaller/getrepositoriesmetainfojob.h index 27245e72a..18c5d3985 100644 --- a/installerbuilder/libinstaller/getrepositoriesmetainfojob.h +++ b/installerbuilder/libinstaller/getrepositoriesmetainfojob.h @@ -65,7 +65,7 @@ public: int silentRetries() const; void setSilentRetries(int retries); - void resetState(); + void reset(); bool isCanceled() const; private Q_SLOTS: diff --git a/installerbuilder/libinstaller/packagemanagercore_p.cpp b/installerbuilder/libinstaller/packagemanagercore_p.cpp index ae3078c55..1f7dfae8e 100644 --- a/installerbuilder/libinstaller/packagemanagercore_p.cpp +++ b/installerbuilder/libinstaller/packagemanagercore_p.cpp @@ -545,11 +545,6 @@ void PackageManagerCorePrivate::initialize() connect(m_repoMetaInfoJob, SIGNAL(infoMessage(KDJob*, QString)), this, SLOT(infoMessage(KDJob*, QString))); } - if (!m_updateFinder) { - m_updateFinder = new KDUpdater::UpdateFinder(&m_updaterApplication); - m_updateFinder->setAutoDelete(false); - m_updateFinder->setUpdateType(KDUpdater::PackageUpdate | KDUpdater::NewPackage); - } } QString PackageManagerCorePrivate::installerBinaryPath() const @@ -1773,11 +1768,15 @@ void PackageManagerCorePrivate::runUndoOperations(const OperationList &undoOpera PackagesList PackageManagerCorePrivate::remotePackages() { - if (m_updates) + if (m_updates && m_updateFinder) return m_updateFinder->updates(); m_updates = false; + delete m_updateFinder; + m_updateFinder = new KDUpdater::UpdateFinder(&m_updaterApplication); + m_updateFinder->setAutoDelete(false); + m_updateFinder->setUpdateType(KDUpdater::PackageUpdate | KDUpdater::NewPackage); m_updateFinder->run(); if (m_updateFinder->updates().isEmpty()) { @@ -1826,8 +1825,11 @@ bool PackageManagerCorePrivate::fetchMetaInformationFromRepositories() if (m_repoFetched) return m_repoFetched; + m_updates = false; m_repoFetched = false; - m_repoMetaInfoJob->resetState(); + m_updateSourcesAdded = false; + + m_repoMetaInfoJob->reset(); if ((isInstaller() && !m_core->isOfflineOnly()) || (isUpdater() || isPackageManager())) m_repoMetaInfoJob->setRepositories(m_settings.repositories()); @@ -1862,7 +1864,17 @@ bool PackageManagerCorePrivate::addUpdateResourcesFromRepositories(bool parseChe return m_updateSourcesAdded; } + // forces an refresh/ clear on all update sources + m_updaterApplication.updateSourcesInfo()->refresh(); + if (isInstaller()) { + m_updaterApplication.addUpdateSource(m_settings.applicationName(), m_settings.applicationName(), + QString(), QUrl(QLatin1String("resource://metadata/")), 0); + m_updaterApplication.updateSourcesInfo()->setModified(false); + } + + m_updates = false; m_updateSourcesAdded = false; + const QString &appName = m_settings.applicationName(); const QStringList tempDirs = m_repoMetaInfoJob->temporaryDirectories(); foreach (const QString &tmpDir, tempDirs) { |