From bdeb3fb0eee3ff013ed948fb759f9c99e0aa5ffe Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 2 Aug 2017 03:33:04 +0200 Subject: updater: remove the updater files after an update Change-Id: Iaf12cb66fae2ead6d899864309f0d7f4d131e072 Reviewed-on: https://gerrit.libreoffice.org/40654 Tested-by: Jenkins Reviewed-by: Markus Mohrhard --- desktop/source/app/app.cxx | 2 ++ desktop/source/app/updater.cxx | 48 ++++++++++++++++++++++++++++++++++++++++++ desktop/source/app/updater.hxx | 4 ++++ 3 files changed, 54 insertions(+) (limited to 'desktop') diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 24545b9502d1..e0dd2a13b682 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1420,6 +1420,8 @@ int Desktop::Main() officecfg::Office::Update::Update::SeeAlso::set(OUString(), batch); officecfg::Office::Update::Update::OldBuildID::set(OUString(), batch); batch->commit(); + + Updater::removeUpdateFiles(); } osl::DirectoryItem aPatchInfo; diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx index 24891fa8ae8e..5e596fc352fe 100644 --- a/desktop/source/app/updater.cxx +++ b/desktop/source/app/updater.cxx @@ -780,6 +780,20 @@ OUString Updater::getUpdateDirURL() return aUpdateDirURL; } + +OUString Updater::getUpdateFileURL() +{ + return getPatchDirURL() + "update.mar"; +} + +OUString Updater::getInstallationPath() +{ + OUString aInstallDir( "$BRAND_BASE_DIR/"); + rtl::Bootstrap::expandMacros(aInstallDir); + + return getPathFromURL(aInstallDir); +} + OUString Updater::getExecutableDirURL() { OUString aExeDir( "$BRAND_BASE_DIR/" LIBO_BIN_FOLDER "/" ); @@ -820,4 +834,38 @@ OUString Updater::getBuildID() return aBuildID; } +void Updater::removeUpdateFiles() +{ + Updater::log("Removing: " + getUpdateFileURL()); + osl::File::remove(getUpdateFileURL()); + + OUString aPatchDirURL = getPatchDirURL(); + osl::Directory aDir(aPatchDirURL); + aDir.open(); + + osl::FileBase::RC eRC; + do + { + osl::DirectoryItem aItem; + eRC = aDir.getNextItem(aItem); + if (eRC == osl::FileBase::E_None) + { + osl::FileStatus aStatus(osl_FileStatus_Mask_All); + if (aItem.getFileStatus(aStatus) != osl::FileBase::E_None) + continue; + + if (!aStatus.isRegular()) + continue; + + OUString aURL = aStatus.getFileURL(); + if (!aURL.endsWith(".mar")) + continue; + + Updater::log("Removing. " + aURL); + osl::File::remove(aURL); + } + } + while (eRC == osl::FileBase::E_None); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/source/app/updater.hxx b/desktop/source/app/updater.hxx index 214777fcba29..5d3d0c2cd98d 100644 --- a/desktop/source/app/updater.hxx +++ b/desktop/source/app/updater.hxx @@ -26,13 +26,17 @@ public: static OUString getUpdateInfoLog(); static OUString getPatchDirURL(); static OUString getUpdateDirURL(); + static OUString getUpdateFileURL(); static OUString getExecutableDirURL(); + static OUString getInstallationPath(); static OUString getBuildID(); static void log(const OUString& rMessage); static void log(const OString& rMessage); static void log(const char* pMessage); + + static void removeUpdateFiles(); }; #endif -- cgit