Kaydet (Commit) 76ed00f8 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

updater: detect when user can not write to installation directory

In this case we can not update right now.

Change-Id: I19cda5ddef448ff81e1ca457774b2db036038c88
üst 44f75d65
...@@ -211,6 +211,35 @@ struct update_info ...@@ -211,6 +211,35 @@ struct update_info
std::vector<language_file> aLanguageFiles; std::vector<language_file> aLanguageFiles;
}; };
bool isUserWritable(const OUString& rFileURL)
{
osl::FileStatus aStatus(osl_FileStatus_Mask_Attributes);
osl::DirectoryItem aDirectoryItem;
osl::FileBase::RC eRes = osl::DirectoryItem::get(rFileURL, aDirectoryItem);
if (eRes != osl::FileBase::E_None)
{
Updater::log("Could not get the directory item for: " + rFileURL);
return false;
}
osl::FileBase::RC eResult = aDirectoryItem.getFileStatus(aStatus);
if (eResult != osl::FileBase::E_None)
{
Updater::log("Could not get the file status for: " + rFileURL);
return false;
}
bool bReadOnly = (aStatus.getAttributes() & static_cast<sal_uInt64>(osl_File_Attribute_ReadOnly)) != 0;
if (bReadOnly)
{
Updater::log("Update location as determined by: " + rFileURL + " is read-only.");
return false;
}
return true;
}
} }
void update() void update()
...@@ -602,6 +631,15 @@ void download_file(const OUString& rURL, size_t nFileSize, const OUString& rHash ...@@ -602,6 +631,15 @@ void download_file(const OUString& rURL, size_t nFileSize, const OUString& rHash
void update_checker() void update_checker()
{ {
OUString aBrandBaseDir("${BRAND_BASE_DIR}");
rtl::Bootstrap::expandMacros(aBrandBaseDir);
bool bUserWritable = isUserWritable(aBrandBaseDir);
if (!bUserWritable)
{
Updater::log("Can't update as the update location is not user writable");
return;
}
OUString aDownloadCheckBaseURL = officecfg::Office::Update::Update::URL::get(); OUString aDownloadCheckBaseURL = officecfg::Office::Update::Update::URL::get();
static const char* pDownloadCheckBaseURLEnv = std::getenv("LIBO_UPDATER_URL"); static const char* pDownloadCheckBaseURLEnv = std::getenv("LIBO_UPDATER_URL");
if (pDownloadCheckBaseURLEnv) if (pDownloadCheckBaseURLEnv)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment