From 8fa32e75b2c06e08785b6b92cb47fc1b4b787ea2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 8 Mar 2016 12:18:39 -0800 Subject: [PATCH] client side fixes for upload with no extension --- assignment-client/src/assets/AssetServer.cpp | 18 ++++++++++++------ interface/src/Application.cpp | 6 +++--- interface/src/assets/ATPAssetMigrator.cpp | 2 +- interface/src/ui/AssetUploadDialogFactory.cpp | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index c6eb314723..cbcce9d45e 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -421,14 +421,20 @@ void AssetServer::loadMappingsFromFile() { QFile mapFile { mapFilePath }; if (mapFile.exists()) { if (mapFile.open(QIODevice::ReadOnly)) { - auto jsonDocument = QJsonDocument::fromJson(mapFile.readAll()); - _fileMappings = jsonDocument.object().toVariantHash(); + QJsonParseError error; - qInfo() << "Loaded" << _fileMappings.count() << "mappings from map file at" << mapFilePath; - } else { - qCritical() << "Failed to read mapping file at" << mapFilePath << "- assignment with not continue."; - setFinished(true); + auto jsonDocument = QJsonDocument::fromJson(mapFile.readAll(), &error); + + if (error.error == QJsonParseError::NoError) { + _fileMappings = jsonDocument.object().toVariantHash(); + + qInfo() << "Loaded" << _fileMappings.count() << "mappings from map file at" << mapFilePath; + return; + } } + + qCritical() << "Failed to read mapping file at" << mapFilePath << "- assignment with not continue."; + setFinished(true); } else { qInfo() << "No existing mappings loaded from file since no file was found at" << mapFilePath; } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 660e597752..fdd9a2c008 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4334,14 +4334,14 @@ void Application::modelUploadFinished(AssetUpload* upload, const QString& hash) auto filename = QFileInfo(upload->getFilename()).fileName(); if ((upload->getError() == AssetUpload::NoError) && - (FBX_EXTENSION.endsWith(upload->getExtension(), Qt::CaseInsensitive) || - OBJ_EXTENSION.endsWith(upload->getExtension(), Qt::CaseInsensitive))) { + (filename.endsWith(FBX_EXTENSION, Qt::CaseInsensitive) || + filename.endsWith(OBJ_EXTENSION, Qt::CaseInsensitive))) { auto entities = DependencyManager::get(); EntityItemProperties properties; properties.setType(EntityTypes::Model); - properties.setModelURL(QString("%1:%2.%3").arg(URL_SCHEME_ATP).arg(hash).arg(upload->getExtension())); + properties.setModelURL(QString("%1:%2").arg(URL_SCHEME_ATP).arg(hash); properties.setPosition(_myCamera.getPosition() + _myCamera.getOrientation() * Vectors::FRONT * 2.0f); properties.setName(QUrl(upload->getFilename()).fileName()); diff --git a/interface/src/assets/ATPAssetMigrator.cpp b/interface/src/assets/ATPAssetMigrator.cpp index dba2047da1..51b2ac558a 100644 --- a/interface/src/assets/ATPAssetMigrator.cpp +++ b/interface/src/assets/ATPAssetMigrator.cpp @@ -142,7 +142,7 @@ void ATPAssetMigrator::migrateResource(ResourceRequest* request) { QFileInfo assetInfo { request->getUrl().fileName() }; - auto upload = assetClient->createUpload(request->getData(), assetInfo.completeSuffix()); + auto upload = assetClient->createUpload(request->getData()); if (upload) { // add this URL to our hash of AssetUpload to original URL diff --git a/interface/src/ui/AssetUploadDialogFactory.cpp b/interface/src/ui/AssetUploadDialogFactory.cpp index 9cd319815b..46f07cb7df 100644 --- a/interface/src/ui/AssetUploadDialogFactory.cpp +++ b/interface/src/ui/AssetUploadDialogFactory.cpp @@ -87,7 +87,7 @@ void AssetUploadDialogFactory::handleUploadFinished(AssetUpload* upload, const Q // setup the line edit to hold the copiable text QLineEdit* lineEdit = new QLineEdit; - QString atpURL = QString("%1:%2.%3").arg(URL_SCHEME_ATP).arg(hash).arg(upload->getExtension()); + QString atpURL = QString("%1:%2").arg(URL_SCHEME_ATP).arg(hash); // set the ATP URL as the text value so it's copiable lineEdit->insert(atpURL);