diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-08-02 03:33:04 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-08-02 07:31:03 +0200 |
commit | bdeb3fb0eee3ff013ed948fb759f9c99e0aa5ffe (patch) | |
tree | 59ec3d85755ffca4ee0cd02cb36ef30ec1075540 /desktop | |
parent | 6d2ef60c30893f5b3771ad645b5680ee4081113a (diff) |
updater: remove the updater files after an update
Change-Id: Iaf12cb66fae2ead6d899864309f0d7f4d131e072
Reviewed-on: https://gerrit.libreoffice.org/40654
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/app/app.cxx | 2 | ||||
-rw-r--r-- | desktop/source/app/updater.cxx | 48 | ||||
-rw-r--r-- | desktop/source/app/updater.hxx | 4 |
3 files changed, 54 insertions, 0 deletions
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 |