From 7079513c23f4bbef81d57d9615dd1e45ebfbe5b9 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 23 Apr 2012 14:49:32 -0400 Subject: IQA-463: Add apr_file_open(APR_CREATE) flag for downloaded installer. This handles the case when the target file doesn't exist, just as APR_TRUNCATE handles the case when it does. Strengthen error checks concerning downloaded installer file from ll_apr_warn_status() to ll_apr_assert_status(). Failing to recognize (e.g.) failure to open that file only leads to mysterious crashes down the road; this removes the mystery. --- indra/viewer_components/updater/llupdatedownloader.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/viewer_components/updater') diff --git a/indra/viewer_components/updater/llupdatedownloader.cpp b/indra/viewer_components/updater/llupdatedownloader.cpp index 5d48c35b4c..abe45cc52b 100644 --- a/indra/viewer_components/updater/llupdatedownloader.cpp +++ b/indra/viewer_components/updater/llupdatedownloader.cpp @@ -347,7 +347,7 @@ size_t LLUpdateDownloader::Implementation::onBody(void * buffer, size_t size) if((size == 0) || (buffer == 0)) return 0; apr_size_t written(size); - ll_apr_warn_status(apr_file_write(mDownloadStream, buffer, &written)); + ll_apr_assert_status(apr_file_write(mDownloadStream, buffer, &written)); return written; } @@ -379,7 +379,7 @@ int LLUpdateDownloader::Implementation::onProgress(double downloadSize, double b void LLUpdateDownloader::Implementation::run(void) { CURLcode code = curl_easy_perform(mCurl); - ll_apr_warn_status(apr_file_close(mDownloadStream)); + ll_apr_assert_status(apr_file_close(mDownloadStream)); mDownloadStream = NULL; if(code == CURLE_OK) { LLFile::remove(mDownloadRecordPath); @@ -459,9 +459,9 @@ void LLUpdateDownloader::Implementation::resumeDownloading(size_t startByte) if(mHeaderList == 0) throw DownloadError("cannot add Range header"); throwOnCurlError(curl_easy_setopt(mCurl, CURLOPT_HTTPHEADER, mHeaderList)); - ll_apr_warn_status(apr_file_open(&mDownloadStream, mDownloadData["path"].asString().c_str(), - APR_WRITE | APR_APPEND | APR_BINARY | APR_BUFFERED, - APR_OS_DEFAULT, gAPRPoolp)); + ll_apr_assert_status(apr_file_open(&mDownloadStream, mDownloadData["path"].asString().c_str(), + APR_WRITE | APR_APPEND | APR_BINARY | APR_BUFFERED, + APR_OS_DEFAULT, gAPRPoolp)); start(); } @@ -484,9 +484,9 @@ void LLUpdateDownloader::Implementation::startDownloading(LLURI const & uri, std llofstream dataStream(mDownloadRecordPath); LLSDSerialize::toPrettyXML(mDownloadData, dataStream); - ll_apr_warn_status(apr_file_open(&mDownloadStream, filePath.c_str(), - APR_WRITE | APR_TRUNCATE | APR_BINARY | APR_BUFFERED, - APR_OS_DEFAULT, gAPRPoolp)); + ll_apr_assert_status(apr_file_open(&mDownloadStream, filePath.c_str(), + APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BINARY | APR_BUFFERED, + APR_OS_DEFAULT, gAPRPoolp)); // IQA-463: Do NOT let this open file be inherited by child processes. // That's why we switched from llofstream to apr_file_t. From // apr_file_open() doc -- cgit v1.2.3