Route FSData download error (which includes 304 - Not Modified) through processResponder() to load data from local file

Thu, 30 Nov 2017 10:55:51 +0100

author
Ansariel
date
Thu, 30 Nov 2017 10:55:51 +0100
changeset 53508
a583abe7a7f8
parent 53507
f5d8ccbfcee0
child 53509
3b6a294f4ad9
child 53510
aa6cfd7d9a13

Route FSData download error (which includes 304 - Not Modified) through processResponder() to load data from local file

indra/newview/fsdata.cpp file | annotate | diff | revisions
indra/newview/fsdata.h file | annotate | diff | revisions
     1.1 --- a/indra/newview/fsdata.cpp	Thu Nov 30 10:18:29 2017 +0100
     1.2 +++ b/indra/newview/fsdata.cpp	Thu Nov 30 10:55:51 2017 +0100
     1.3 @@ -118,7 +118,7 @@
     1.4  		else
     1.5  		{
     1.6  			processData(content);
     1.7 -			saveLLSD(content , mFSdataFilename, last_modified);
     1.8 +			saveLLSD(content, mFSdataFilename, last_modified);
     1.9  		}
    1.10  		mFSDataDone = true;
    1.11  	}
    1.12 @@ -140,7 +140,7 @@
    1.13  		else
    1.14  		{
    1.15  			processAssets(content);
    1.16 -			saveLLSD(content , mAssestsFilename, last_modified);
    1.17 +			saveLLSD(content, mAssestsFilename, last_modified);
    1.18  		}
    1.19  	}
    1.20  	else if (url == mAgentsURL)
    1.21 @@ -161,7 +161,7 @@
    1.22  		else
    1.23  		{
    1.24  			processAgents(content);
    1.25 -			saveLLSD(content , mAgentsFilename, last_modified);
    1.26 +			saveLLSD(content, mAgentsFilename, last_modified);
    1.27  		}
    1.28  		mAgentsDone = true;
    1.29  		addAgents();
    1.30 @@ -175,7 +175,7 @@
    1.31  		else
    1.32  		{
    1.33  			processClientTags(content);
    1.34 -			saveLLSD(content , mClientTagsFilename, last_modified);
    1.35 +			saveLLSD(content, mClientTagsFilename, last_modified);
    1.36  		}
    1.37  	}
    1.38  	else if (url == mFSdataDefaultsUrl)
    1.39 @@ -186,7 +186,7 @@
    1.40  		}
    1.41  		else
    1.42  		{
    1.43 -			saveLLSD(content , mFSdataDefaultsFilename, last_modified);
    1.44 +			saveLLSD(content, mFSdataDefaultsFilename, last_modified);
    1.45  		}
    1.46  	}
    1.47  }
    1.48 @@ -215,38 +215,38 @@
    1.49  	}
    1.50  }
    1.51  
    1.52 -void downloadComplete( LLSD const &aData, std::string const &aURL )
    1.53 +void downloadComplete(LLSD const &aData, std::string const &aURL, bool success)
    1.54  {
    1.55 -	LL_DEBUGS() << aData << LL_ENDL;
    1.56 +	LL_DEBUGS("fsdata") << aData << LL_ENDL;
    1.57  	
    1.58 -	LLSD header = aData[ LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS ][ LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS];
    1.59 +	LLSD header = aData[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS][LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS];
    1.60  
    1.61  	LLDate lastModified;
    1.62  	if (header.has("last-modified"))
    1.63  	{
    1.64 -		lastModified.secondsSinceEpoch( FSCommon::secondsSinceEpochFromString( "%a, %d %b %Y %H:%M:%S %ZP", header["last-modified"].asString() ) );
    1.65 +		lastModified.secondsSinceEpoch(FSCommon::secondsSinceEpochFromString("%a, %d %b %Y %H:%M:%S %ZP", header["last-modified"].asString()));
    1.66  	}
    1.67  
    1.68  	LLSD data = aData;
    1.69 -	data.erase( LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS );
    1.70 +	data.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS);
    1.71  	
    1.72 -	FSData::getInstance()->processResponder( data, aURL, true, lastModified);
    1.73 +	FSData::getInstance()->processResponder(data, aURL, success, lastModified);
    1.74  }
    1.75  
    1.76 -void downloadCompleteScript( LLSD const &aData, std::string const &aURL, std::string const &aFilename  )
    1.77 +void downloadCompleteScript(LLSD const &aData, std::string const &aURL, std::string const &aFilename)
    1.78  {
    1.79 -	LL_DEBUGS() << aData << LL_ENDL;
    1.80 -	LLSD header = aData[ LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS ][ LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS];
    1.81 -	LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD( aData[ LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS ] );
    1.82 +	LL_DEBUGS("fsdata") << aData << LL_ENDL;
    1.83 +	LLSD header = aData[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS][LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_HEADERS];
    1.84 +	LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(aData[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]);
    1.85  
    1.86  	LLDate lastModified;
    1.87  	if (header.has("last-modified"))
    1.88  	{
    1.89 -		lastModified.secondsSinceEpoch( FSCommon::secondsSinceEpochFromString( "%a, %d %b %Y %H:%M:%S %ZP", header["last-modified"].asString() ) );
    1.90 +		lastModified.secondsSinceEpoch(FSCommon::secondsSinceEpochFromString("%a, %d %b %Y %H:%M:%S %ZP", header["last-modified"].asString()));
    1.91  	}
    1.92  	const LLSD::Binary &rawData = aData[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary();
    1.93  
    1.94 -	if ( status.getType() == HTTP_NOT_MODIFIED )
    1.95 +	if (status.getType() == HTTP_NOT_MODIFIED)
    1.96  	{
    1.97  		LL_INFOS("fsdata") << "Got [304] not modified for " << aURL << LL_ENDL;
    1.98  		return;
    1.99 @@ -282,22 +282,9 @@
   1.100  	}
   1.101  }
   1.102  
   1.103 -void downloadError( LLSD const &aData, std::string const &aURL )
   1.104 +void downloadError(LLSD const &aData, std::string const &aURL)
   1.105  {
   1.106 -	LL_WARNS() << "Failed to download " << aURL << ": " << aData << LL_ENDL;
   1.107 -	FSData::instance().checkDone(aURL);
   1.108 -}
   1.109 -
   1.110 -void FSData::checkDone(const std::string& url)
   1.111 -{
   1.112 -	if (url == mFSDataURL)
   1.113 -	{
   1.114 -		mFSDataDone = true;
   1.115 -	}
   1.116 -	else if (url == mAgentsURL)
   1.117 -	{
   1.118 -		mAgentsDone = true;
   1.119 -	}
   1.120 +	LL_WARNS("fsdata") << "Failed to download " << aURL << ": " << aData << LL_ENDL;
   1.121  }
   1.122  
   1.123  // call this just before the login screen and after the LLProxy has been setup.
   1.124 @@ -315,7 +302,7 @@
   1.125  		last_modified = stat_data.st_mtime;
   1.126  	}
   1.127  	LL_INFOS("fsdata") << "Downloading data.xml from " << mFSDataURL << " with last modifed of " << last_modified << LL_ENDL;
   1.128 -	FSCoreHttpUtil::callbackHttpGet(mFSDataURL, last_modified, boost::bind(downloadComplete, _1, mFSDataURL), boost::bind(downloadError, _1, mFSDataURL));
   1.129 +	FSCoreHttpUtil::callbackHttpGet(mFSDataURL, last_modified, boost::bind(downloadComplete, _1, mFSDataURL, true), boost::bind(downloadComplete, _1, mFSDataURL, false));
   1.130  
   1.131  	last_modified = 0;
   1.132  	if(!LLFile::stat(mFSdataDefaultsFilename, &stat_data))
   1.133 @@ -325,7 +312,7 @@
   1.134  	std::string filename = llformat("defaults.%s.xml", LLVersionInfo::getShortVersion().c_str());
   1.135  	mFSdataDefaultsUrl = mBaseURL + "/" + filename;
   1.136  	LL_INFOS("fsdata") << "Downloading defaults.xml from " << mFSdataDefaultsUrl << " with last modifed of " << last_modified << LL_ENDL;
   1.137 -	FSCoreHttpUtil::callbackHttpGet(mFSdataDefaultsUrl, last_modified, boost::bind(downloadComplete, _1, mFSdataDefaultsUrl), boost::bind(downloadError, _1, mFSdataDefaultsUrl));
   1.138 +	FSCoreHttpUtil::callbackHttpGet(mFSdataDefaultsUrl, last_modified, boost::bind(downloadComplete, _1, mFSdataDefaultsUrl, true), boost::bind(downloadComplete, _1, mFSdataDefaultsUrl, false));
   1.139  
   1.140  #if OPENSIM
   1.141  	std::string filenames[] = {"scriptlibrary_ossl.xml", "scriptlibrary_aa.xml"};
   1.142 @@ -383,7 +370,7 @@
   1.143  			last_modified = stat_data.st_mtime;
   1.144  		}
   1.145  		LL_INFOS("fsdata") << "Downloading agents.xml from " << mAgentsURL << " with last modifed of " << last_modified << LL_ENDL;
   1.146 -		FSCoreHttpUtil::callbackHttpGet(mAgentsURL, last_modified, boost::bind(downloadComplete, _1, mAgentsURL), boost::bind(downloadError, _1, mAgentsURL));
   1.147 +		FSCoreHttpUtil::callbackHttpGet(mAgentsURL, last_modified, boost::bind(downloadComplete, _1, mAgentsURL, true), boost::bind(downloadComplete, _1, mAgentsURL, false));
   1.148  	}
   1.149  
   1.150  	if (!mAssetsURL.empty())
   1.151 @@ -396,7 +383,7 @@
   1.152  			last_modified = stat_data.st_mtime;
   1.153  		}
   1.154  		LL_INFOS("fsdata") << "Downloading assets.xml from " << mAssetsURL << " with last modifed of " << last_modified << LL_ENDL;
   1.155 -		FSCoreHttpUtil::callbackHttpGet(mAssetsURL, last_modified, boost::bind(downloadComplete, _1, mAssetsURL), boost::bind(downloadError, _1, mAssetsURL));
   1.156 +		FSCoreHttpUtil::callbackHttpGet(mAssetsURL, last_modified, boost::bind(downloadComplete, _1, mAssetsURL, true), boost::bind(downloadComplete, _1, mAssetsURL, false));
   1.157  	}
   1.158  }
   1.159  
   1.160 @@ -463,7 +450,7 @@
   1.161  			last_modified = stat_data.st_mtime;
   1.162  		}
   1.163  		LL_INFOS("fsdata") << "Downloading client_list_v2.xml from " << LEGACY_CLIENT_LIST_URL << " with last modifed of " << last_modified << LL_ENDL;
   1.164 -		FSCoreHttpUtil::callbackHttpGet(LEGACY_CLIENT_LIST_URL, last_modified, boost::bind(downloadComplete, _1, LEGACY_CLIENT_LIST_URL), boost::bind(downloadError, _1, LEGACY_CLIENT_LIST_URL));
   1.165 +		FSCoreHttpUtil::callbackHttpGet(LEGACY_CLIENT_LIST_URL, last_modified, boost::bind(downloadComplete, _1, LEGACY_CLIENT_LIST_URL, true), boost::bind(downloadComplete, _1, LEGACY_CLIENT_LIST_URL, false));
   1.166  	}
   1.167  	else if(use_legacy_tags)
   1.168  	{
     2.1 --- a/indra/newview/fsdata.h	Thu Nov 30 10:18:29 2017 +0100
     2.2 +++ b/indra/newview/fsdata.h	Thu Nov 30 10:55:51 2017 +0100
     2.3 @@ -79,7 +79,6 @@
     2.4  	std::string getOpenSimMOTD() { return mOpensimMOTD; }
     2.5  	bool getFSDataDone() { return mFSDataDone; }
     2.6  	bool getAgentsDone() { return mAgentsDone; }
     2.7 -	void checkDone(const std::string& url);
     2.8  
     2.9  	bool isAgentFlag(const LLUUID& agent_id, FSData::flags_t flag);
    2.10  

mercurial