mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 19:50:03 -06:00
Make SyncTask work with globebrowsing scripts
Add additional error information to http request
This commit is contained in:
@@ -128,25 +128,25 @@ int main(int argc, char** argv) {
|
||||
FactoryManager::ref().addFactory(
|
||||
std::make_unique<ghoul::TemplateFactory<Renderable>>(),
|
||||
"Renderable"
|
||||
);
|
||||
);
|
||||
FactoryManager::ref().addFactory(
|
||||
std::make_unique<ghoul::TemplateFactory<Task>>(),
|
||||
"Task"
|
||||
);
|
||||
);
|
||||
FactoryManager::ref().addFactory(
|
||||
std::make_unique<ghoul::TemplateFactory<Translation>>(),
|
||||
"Translation"
|
||||
);
|
||||
);
|
||||
|
||||
FactoryManager::ref().addFactory(
|
||||
std::make_unique<ghoul::TemplateFactory<Rotation>>(),
|
||||
"Rotation"
|
||||
);
|
||||
);
|
||||
|
||||
FactoryManager::ref().addFactory(
|
||||
std::make_unique<ghoul::TemplateFactory<Scale>>(),
|
||||
"Scale"
|
||||
);
|
||||
);
|
||||
FactoryManager::ref().addFactory(
|
||||
std::make_unique<ghoul::TemplateFactory<ResourceSynchronization>>(),
|
||||
"ResourceSynchronization"
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
return {{
|
||||
Type = "SyncAssetTask",
|
||||
Asset = "solarsystem"
|
||||
},
|
||||
{
|
||||
Type = "SyncAssetTask",
|
||||
Asset = "newhorizons"
|
||||
}}
|
||||
return {
|
||||
{
|
||||
Type = "SyncAssetTask",
|
||||
Asset = "dawn"
|
||||
},
|
||||
{
|
||||
Type = "SyncAssetTask",
|
||||
Asset = "default"
|
||||
},
|
||||
{
|
||||
Type = "SyncAssetTask",
|
||||
Asset = "newhorizons"
|
||||
},
|
||||
{
|
||||
Type = "SyncAssetTask",
|
||||
Asset = "osirisrex"
|
||||
},
|
||||
{
|
||||
Type = "SyncAssetTask",
|
||||
Asset = "rosetta"
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,9 @@
|
||||
|
||||
#include <modules/sync/tasks/syncassettask.h>
|
||||
|
||||
#include <openspace/moduleregistration.h>
|
||||
#include <openspace/openspace.h>
|
||||
#include <openspace/documentation/core_registration.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/util/synchronizationwatcher.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
@@ -45,8 +47,7 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
SyncAssetTask::SyncAssetTask(const ghoul::Dictionary& dictionary)
|
||||
{
|
||||
SyncAssetTask::SyncAssetTask(const ghoul::Dictionary& dictionary) {
|
||||
openspace::documentation::testSpecificationAndThrow(
|
||||
documentation(),
|
||||
dictionary,
|
||||
@@ -64,6 +65,17 @@ void SyncAssetTask::perform(const Task::ProgressCallback & progressCallback) {
|
||||
SynchronizationWatcher watcher;
|
||||
|
||||
scripting::ScriptEngine scriptEngine;
|
||||
|
||||
registerCoreClasses(scriptEngine);
|
||||
|
||||
for (OpenSpaceModule* m : AllModules()) {
|
||||
scriptEngine.addLibrary(m->luaLibrary());
|
||||
|
||||
for (scripting::LuaLibrary& l : m->luaLibraries()) {
|
||||
scriptEngine.addLibrary(l);
|
||||
}
|
||||
}
|
||||
|
||||
scriptEngine.initialize();
|
||||
|
||||
ghoul::lua::LuaState luaState;
|
||||
@@ -79,7 +91,7 @@ void SyncAssetTask::perform(const Task::ProgressCallback & progressCallback) {
|
||||
|
||||
std::vector<std::shared_ptr<Asset>> allAssets = loader.rootAsset()->subTreeAssets();
|
||||
|
||||
while (true) {
|
||||
while (true) {
|
||||
bool inProgress = false;
|
||||
for (const std::shared_ptr<Asset>& asset : allAssets) {
|
||||
Asset::State state = asset->state();
|
||||
|
||||
@@ -332,6 +332,39 @@ bool HttpFileDownload::initDownload() {
|
||||
_file = std::ofstream(_destination, std::ofstream::binary);
|
||||
|
||||
if (_file.fail()) {
|
||||
#ifdef WIN32
|
||||
// GetLastError() gives more details than errno.
|
||||
if (GetLastError() != 0) {
|
||||
LERROR(
|
||||
"Cannot open file " << destinationFile <<
|
||||
": " << FormatSystemMessage(GetLastError()
|
||||
);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
LERROR("Cannot open file " << destinationFile);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (errno) {
|
||||
#if defined(__unix__)
|
||||
// We use strerror_r because it's threadsafe.
|
||||
// GNU's strerror_r returns a string and may ignore buffer completely.
|
||||
char buffer[255];
|
||||
LERROR(
|
||||
"Cannot open file " << destinationFile << ": " <<
|
||||
std::string(strerror_r(errno, buffer, sizeof(buffer)))
|
||||
);
|
||||
return false;
|
||||
#else
|
||||
LERROR(
|
||||
"Cannot open file " << destinationFile << ": " <<
|
||||
std::string(strerror(errno))
|
||||
);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
LERROR("Cannot open file " << destinationFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user