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/source/app/updater.cxx | |
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/source/app/updater.cxx')
-rw-r--r-- | desktop/source/app/updater.cxx | 48 |
1 files changed, 48 insertions, 0 deletions
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: */ |