mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
More panda3d.exe robustness: make sure contents.xml is fresh if core API fails hash check
This commit is contained in:
parent
9053999889
commit
dbb83409e0
@ -356,6 +356,7 @@ bool Panda3D::
|
|||||||
get_plugin() {
|
get_plugin() {
|
||||||
// First, look for the existing contents.xml file.
|
// First, look for the existing contents.xml file.
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
bool is_fresh = false;
|
||||||
|
|
||||||
Filename contents_filename = Filename(Filename::from_os_specific(_root_dir), "contents.xml");
|
Filename contents_filename = Filename(Filename::from_os_specific(_root_dir), "contents.xml");
|
||||||
if (_verify_contents != P3D_VC_force) {
|
if (_verify_contents != P3D_VC_force) {
|
||||||
@ -370,6 +371,38 @@ get_plugin() {
|
|||||||
if (!success) {
|
if (!success) {
|
||||||
// Couldn't read it (or it wasn't current enough), so go get a new
|
// Couldn't read it (or it wasn't current enough), so go get a new
|
||||||
// one.
|
// one.
|
||||||
|
if (!download_contents_file(contents_filename)) {
|
||||||
|
// We don't have a usable contents.xml file.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
is_fresh = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now that we've downloaded the contents file successfully, start
|
||||||
|
// the Core API.
|
||||||
|
if (!get_core_api()) {
|
||||||
|
// We failed. Make sure contents.xml is up-to-date and try again.
|
||||||
|
if (!is_fresh && download_contents_file(contents_filename) && get_core_api()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Panda3D::download_contents_file
|
||||||
|
// Access: Protected
|
||||||
|
// Description: Redownloads the contents.xml file from the named
|
||||||
|
// URL without first checking if it is up to date.
|
||||||
|
// Returns true if we have a contents.xml file that
|
||||||
|
// might be usable, false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool Panda3D::
|
||||||
|
download_contents_file(const Filename &contents_filename) {
|
||||||
|
bool success = false;
|
||||||
HTTPClient *http = HTTPClient::get_global_ptr();
|
HTTPClient *http = HTTPClient::get_global_ptr();
|
||||||
|
|
||||||
// Try the super_mirror first.
|
// Try the super_mirror first.
|
||||||
@ -433,13 +466,6 @@ get_plugin() {
|
|||||||
|
|
||||||
tempfile.unlink();
|
tempfile.unlink();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
// Now that we've downloaded the contents file successfully, start
|
|
||||||
// the Core API.
|
|
||||||
success = get_core_api();
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@ -835,7 +861,6 @@ download_core_api() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
cerr << "Couldn't download core API.\n";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
bool post_arg_processing();
|
bool post_arg_processing();
|
||||||
bool get_plugin();
|
bool get_plugin();
|
||||||
|
bool download_contents_file(const Filename &contents_filename);
|
||||||
bool read_contents_file(const Filename &contents_filename, bool fresh_download);
|
bool read_contents_file(const Filename &contents_filename, bool fresh_download);
|
||||||
void find_host(TiXmlElement *xcontents);
|
void find_host(TiXmlElement *xcontents);
|
||||||
void read_xhost(TiXmlElement *xhost);
|
void read_xhost(TiXmlElement *xhost);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user