mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Iss asset with model added
This commit is contained in:
@@ -43,8 +43,10 @@ namespace {
|
||||
constexpr const char* KeyIdentifier = "Identifier";
|
||||
constexpr const char* KeyOverride = "Override";
|
||||
constexpr const char* KeyUseHash = "UseHash";
|
||||
constexpr const char* KeyFilename = "Filename";
|
||||
|
||||
constexpr const char* TempSuffix = ".tmp";
|
||||
constexpr const char* ext = ".txt";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -90,6 +92,13 @@ documentation::Documentation UrlSynchronization::Documentation() {
|
||||
"circumstances. If this is not desired, the URLSynchronization use the "
|
||||
"bare directory name alone if this value is 'false'. If this value is "
|
||||
"'false', the identifier has to be specified."
|
||||
},
|
||||
{
|
||||
KeyFilename,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
"Optional to provide filename to override the one which is automatically "
|
||||
"created from the url. "
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -117,6 +126,14 @@ UrlSynchronization::UrlSynchronization(const ghoul::Dictionary& dict,
|
||||
}
|
||||
}
|
||||
|
||||
if (dict.hasValue<std::string>(KeyFilename)) {
|
||||
_filename = dict.value<std::string>(KeyFilename);
|
||||
std::size_t foundExt = _filename.find(ext);
|
||||
if (foundExt == std::string::npos) {
|
||||
_filename += ext;
|
||||
}
|
||||
}
|
||||
|
||||
bool useHash = true;
|
||||
if (dict.hasValue<bool>(KeyUseHash)) {
|
||||
useHash = dict.value<bool>(KeyUseHash);
|
||||
@@ -181,11 +198,21 @@ void UrlSynchronization::start() {
|
||||
std::vector<std::unique_ptr<AsyncHttpFileDownload>> downloads;
|
||||
|
||||
for (const std::string& url : _urls) {
|
||||
const size_t lastSlash = url.find_last_of('/');
|
||||
const std::string filename = url.substr(lastSlash + 1);
|
||||
|
||||
if (_filename.empty()) {
|
||||
const size_t lastSlash = url.find_last_of('/');
|
||||
std::string lastPartOfUrl = url.substr(lastSlash + 1);
|
||||
|
||||
lastPartOfUrl.erase(std::remove(lastPartOfUrl.begin(), lastPartOfUrl.end(), '?'), lastPartOfUrl.end());
|
||||
|
||||
std::size_t foundExt = lastPartOfUrl.find(ext);
|
||||
if (foundExt == std::string::npos) {
|
||||
lastPartOfUrl += ext;
|
||||
}
|
||||
_filename = lastPartOfUrl;
|
||||
}
|
||||
std::string fileDestination = directory() +
|
||||
ghoul::filesystem::FileSystem::PathSeparator + filename + TempSuffix;
|
||||
ghoul::filesystem::FileSystem::PathSeparator + _filename + TempSuffix;
|
||||
|
||||
std::unique_ptr<AsyncHttpFileDownload> download =
|
||||
std::make_unique<AsyncHttpFileDownload>(
|
||||
|
||||
Reference in New Issue
Block a user