bin/update/tools.py | 7 +++++- desktop/source/app/app.cxx | 3 +- desktop/source/app/updater.cxx | 47 ++++++++++++++++++++++++++++++----------- 3 files changed, 43 insertions(+), 14 deletions(-)
New commits: commit 257fb1141f2dcb22d3ac6c8bb63af94bc3d652af Author: Markus Mohrhard <[email protected]> Date: Sun Aug 20 00:23:11 2017 +0200 updater: replace whitespace in dir names and strip the extra win dir layer Change-Id: I543b903157d44038468eb4d92261dfd0d8b2909b diff --git a/bin/update/tools.py b/bin/update/tools.py index 1e14f793cceb..8cd786635f0d 100644 --- a/bin/update/tools.py +++ b/bin/update/tools.py @@ -20,7 +20,12 @@ def uncompress_file_to_dir(compressed_file, uncompress_dir): zip_file = zipfile.ZipFile(compressed_file) zip_file.extractall(uncompress_dir) zip_file.close() - pass + + uncompress_dir = os.path.join(uncompress_dir, os.listdir(uncompress_dir)[0]) + if " " in os.listdir(uncompress_dir)[0]: + print("replacing whitespace in directory name") + os.rename(os.path.join(uncompress_dir, os.listdir(uncompress_dir)[0]), + os.path.join(uncompress_dir, os.listdir(uncompress_dir)[0].replace(" ", "_"))) else: print("Error: unknown extension " + extension) commit 5daa3a1cc0bced06c638952ececf4299ef71183a Author: Markus Mohrhard <[email protected]> Date: Sat Aug 19 22:10:27 2017 +0200 updater: make it easier to test some parts of the updating code Change-Id: I7f3758eb8c12d912a47ac3a3c632347e6e124601 diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index f71355c03b7a..209c0d7d8ed2 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1427,6 +1427,7 @@ int Desktop::Main() osl::DirectoryItem::get(Updater::getUpdateFileURL(), aUpdateFile); const char* pUpdaterTestUpdate = std::getenv("LIBO_UPDATER_TEST_UPDATE"); + const char* pForcedUpdateCheck = std::getenv("LIBO_UPDATER_TEST_UPDATE_CHECK"); if (pUpdaterTestUpdate || aUpdateFile.is()) { OUString aBuildID("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("version") ":buildid}"); @@ -1446,7 +1447,7 @@ int Desktop::Main() if (bSuccess) return EXIT_SUCCESS; } - else if (isTimeForUpdateCheck()) + else if (isTimeForUpdateCheck() || pForcedUpdateCheck) { sal_uInt64 nNow = tools::Time::GetSystemTicks(); Updater::log("Update Check Time: " + OUString::number(nNow)); diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx index 73a3bd993476..4049b0ab3472 100644 --- a/desktop/source/app/updater.cxx +++ b/desktop/source/app/updater.cxx @@ -678,6 +678,13 @@ void update_checker() OUString aProductName = utl::ConfigManager::getProductName(); OUString aBuildID = Updater::getBuildID(); + + static const char* pBuildIdEnv = std::getenv("LIBO_UPDATER_BUILD"); + if (pBuildIdEnv) + { + aBuildID = OUString::createFromAscii(pBuildIdEnv); + } + OUString aBuildTarget = "${_OS}_${_ARCH}"; rtl::Bootstrap::expandMacros(aBuildTarget); OUString aChannel = officecfg::Office::Update::Update::UpdateChannel::get(); commit 3f8a48f5d81baee92f83a666842b7322195d6116 Author: Markus Mohrhard <[email protected]> Date: Sat Aug 19 22:09:56 2017 +0200 updater: windows prevents moving file with open file handles Change-Id: Iebd4886f3d44f816fc06b7c80e7368bbac3d159a diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx index a034dc3a478e..73a3bd993476 100644 --- a/desktop/source/app/updater.cxx +++ b/desktop/source/app/updater.cxx @@ -651,6 +651,7 @@ void download_file(const OUString& rURL, size_t nFileSize, const OUString& rHash OUString aDestFile = aPatchDirURL + aFileName; Updater::log("Destination File: " + aDestFile); + aDownloadedFile.close(); eError = osl::File::move(aTempFile, aDestFile); handle_file_error(eError, "Could not move the file from the Temp directory to the user config: TempFile: " + aTempFile + "; DestFile: " + aDestFile); } commit 575cf048132c905e91bf2266be93e245c993498f Author: Markus Mohrhard <[email protected]> Date: Sat Aug 19 19:22:03 2017 +0200 updater: better error logging Change-Id: I9acdfc6e493bc8ae6d2335e5aae65699bf2665c0 diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx index f5955bc8b5e5..a034dc3a478e 100644 --- a/desktop/source/app/updater.cxx +++ b/desktop/source/app/updater.cxx @@ -48,6 +48,18 @@ namespace { class error_updater : public std::exception { + OString maStr; +public: + + error_updater(const OString& rStr): + maStr(rStr) + { + } + + virtual const char* what() const override + { + return maStr.getStr(); + } }; #ifdef UNX @@ -576,13 +588,13 @@ std::string download_content(const OString& rURL, bool bFile, OUString& rHash) if (http_code != 200) { SAL_WARN("desktop.updater", "download did not succeed. Error code: " << http_code); - throw error_updater(); + throw error_updater("download did not succeed"); } if (cc != CURLE_OK) { SAL_WARN("desktop.updater", "curl error: " << cc); - throw error_updater(); + throw error_updater("curl error"); } if (bFile) @@ -591,34 +603,36 @@ std::string download_content(const OString& rURL, bool bFile, OUString& rHash) return response_body; } -void handle_file_error(osl::FileBase::RC eError) +void handle_file_error(osl::FileBase::RC eError, const OUString& rMsg) { switch (eError) { case osl::FileBase::E_None: break; default: - SAL_WARN("desktop.updater", "file error code: " << eError); - throw error_updater(); + SAL_WARN("desktop.updater", "file error code: " << eError << ", " << rMsg); + throw error_updater(OUStringToOString(rMsg, RTL_TEXTENCODING_UTF8)); } } void download_file(const OUString& rURL, size_t nFileSize, const OUString& rHash, const OUString& aFileName) { + Updater::log("Download File: " + rURL + "; FileName: " + aFileName); OString aURL = OUStringToOString(rURL, RTL_TEXTENCODING_UTF8); OUString aHash; std::string temp_file = download_content(aURL, true, aHash); if (temp_file.empty()) - throw error_updater(); + throw error_updater("empty temp file string"); OUString aTempFile = OUString::fromUtf8(temp_file.c_str()); + Updater::log("TempFile: " + aTempFile); osl::File aDownloadedFile(aTempFile); osl::FileBase::RC eError = aDownloadedFile.open(1); - handle_file_error(eError); + handle_file_error(eError, "Could not open the download file: " + aTempFile); sal_uInt64 nSize = 0; eError = aDownloadedFile.getSize(nSize); - handle_file_error(eError); + handle_file_error(eError, "Could not get the file size of the downloaded file: " + aTempFile); if (nSize != nFileSize) { SAL_WARN("desktop.updater", "File sizes don't match. File might be corrupted."); @@ -636,8 +650,9 @@ void download_file(const OUString& rURL, size_t nFileSize, const OUString& rHash osl::Directory::create(aPatchDirURL); OUString aDestFile = aPatchDirURL + aFileName; + Updater::log("Destination File: " + aDestFile); eError = osl::File::move(aTempFile, aDestFile); - handle_file_error(eError); + handle_file_error(eError, "Could not move the file from the Temp directory to the user config: TempFile: " + aTempFile + "; DestFile: " + aDestFile); } } @@ -718,10 +733,10 @@ void update_checker() SAL_WARN("desktop.updater", "invalid update information"); Updater::log(OString("warning: invalid update info")); } - catch (const error_updater&) + catch (const error_updater& e) { - SAL_WARN("desktop.updater", "error during the update check"); - Updater::log(OString("warning: error by the updater")); + SAL_WARN("desktop.updater", "error during the update check: " << e.what()); + Updater::log(OString("warning: error by the updater") + e.what()); } catch (const invalid_size& e) { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
