Пример #1
0
bool LLUpdaterServiceImpl::checkForResume()
{
	bool result = false;
	std::string download_marker_path = mUpdateDownloader.downloadMarkerPath();
	if(LLFile::isfile(download_marker_path))
	{
		llifstream download_marker_stream(download_marker_path, 
								 std::ios::in | std::ios::binary);
		if(download_marker_stream.is_open())
		{
			LLSD download_info;
			LLSDSerialize::fromXMLDocument(download_info, download_marker_stream);
			download_marker_stream.close();
			if(download_info["current_version"].asString() == ll_get_version())
			{
				mIsDownloading = true;
				mNewVersion = download_info["update_version"].asString();
				mUpdateDownloader.resume();
				result = true;
			}
			else 
			{
				// The viewer that started this download is not the same as this viewer; ignore.
				llinfos << "ignoring partial download from different viewer version" << llendl;
				std::string path = download_info["path"].asString();
				if(!path.empty()) LLFile::remove(path);
				LLFile::remove(download_marker_path);
			}
		} 
	}
	return result;
}
void LLUpdateDownloader::Implementation::startDownloading(LLURI const & uri, std::string const & hash)
{
	mDownloadData["url"] = uri.asString();
	mDownloadData["hash"] = hash;
	mDownloadData["current_version"] = ll_get_version();
	LLSD path = uri.pathArray();
	if(path.size() == 0) throw DownloadError("no file path");
	std::string fileName = path[path.size() - 1].asString();
	std::string filePath = gDirUtilp->getExpandedFilename(LL_PATH_TEMP, fileName);
	mDownloadData["path"] = filePath;

	LL_INFOS("UpdateDownload") << "downloading " << filePath
		<< " from " << uri.asString() << LL_ENDL;
	LL_INFOS("UpdateDownload") << "hash of file is " << hash << LL_ENDL;
		
	llofstream dataStream(mDownloadRecordPath);
	LLSDSerialize::toPrettyXML(mDownloadData, dataStream);
	
	mDownloadStream.open(filePath, std::ios_base::out | std::ios_base::binary);
	initializeCurlGet(uri.asString(), true);
	start();
}
bool LLUpdaterServiceImpl::checkForInstall(bool launchInstaller)
{
    bool foundInstall = false; // return true if install is found.

    llifstream update_marker(update_marker_path().c_str(),
                             std::ios::in | std::ios::binary);

    if(update_marker.is_open())
    {
        // Found an update info - now lets see if its valid.
        LLSD update_info;
        LLSDSerialize::fromXMLDocument(update_info, update_marker);
        update_marker.close();

        // Get the path to the installer file.
        std::string path(update_info.get("path"));
        std::string downloader_version(update_info["current_version"]);
        if (downloader_version != ll_get_version())
        {
            // This viewer is not the same version as the one that downloaded
            // the update. Do not install this update.
            LL_INFOS("UpdaterService") << "ignoring update downloaded by "
                                       << "different viewer version "
                                       << downloader_version << LL_ENDL;
            if (! path.empty())
            {
                LL_INFOS("UpdaterService") << "removing " << path << LL_ENDL;
                LLFile::remove(path);
                LLFile::remove(update_marker_path());
            }

            foundInstall = false;
        }
        else if (path.empty())
        {
            LL_WARNS("UpdaterService") << "Marker file " << update_marker_path()
                                       << " 'path' entry empty, ignoring" << LL_ENDL;
            foundInstall = false;
        }
        else if (! LLFile::isfile(path))
        {
            LL_WARNS("UpdaterService") << "Nonexistent installer " << path
                                       << ", ignoring" << LL_ENDL;
            foundInstall = false;
        }
        else
        {
            if(launchInstaller)
            {
                setState(LLUpdaterService::INSTALLING);

                LLFile::remove(update_marker_path());

                int result = ll_install_update(install_script_path(),
                                               path,
                                               update_info["required"].asBoolean(),
                                               install_script_mode());

                if((result == 0) && mAppExitCallback)
                {
                    mAppExitCallback();
                }
                else if(result != 0)
                {
                    LL_WARNS("UpdaterService") << "failed to run update install script" << LL_ENDL;
                }
                else
                {
                    ; // No op.
                }
            }

            foundInstall = true;
        }
    }
    return foundInstall;
}
Пример #4
0
bool LLUpdaterServiceImpl::checkForInstall(bool launchInstaller)
{
	bool foundInstall = false; // return true if install is found.

	llifstream update_marker(update_marker_path(), 
							 std::ios::in | std::ios::binary);

	if(update_marker.is_open())
	{
		// Found an update info - now lets see if its valid.
		LLSD update_info;
		LLSDSerialize::fromXMLDocument(update_info, update_marker);
		update_marker.close();

		// Get the path to the installer file.
		LLSD path = update_info.get("path");
		if(update_info["current_version"].asString() != ll_get_version())
		{
			// This viewer is not the same version as the one that downloaded
			// the update.  Do not install this update.
			if(!path.asString().empty())
			{
				llinfos << "ignoring update dowloaded by different client version" << llendl;
				LLFile::remove(path.asString());
				LLFile::remove(update_marker_path());
			}
			else
			{
				; // Nothing to clean up.
			}
			
			foundInstall = false;
		} 
		else if(path.isDefined() && !path.asString().empty())
		{
			if(launchInstaller)
			{
				setState(LLUpdaterService::INSTALLING);
				
				LLFile::remove(update_marker_path());

				int result = ll_install_update(install_script_path(),
											   update_info["path"].asString(),
											   update_info["required"].asBoolean(),
											   install_script_mode());	
				
				if((result == 0) && mAppExitCallback)
				{
					mAppExitCallback();
				} else if(result != 0) {
					llwarns << "failed to run update install script" << LL_ENDL;
				} else {
					; // No op.
				}
			}
			
			foundInstall = true;
		}
	}
	return foundInstall;
}