file structures in zip files replicated, more useful unzip debug print, updated blocks tablet app url

This commit is contained in:
Elisa Lupin-Jimenez 2017-11-17 15:54:41 -08:00
parent 88823a169b
commit 3aa7cb440d
2 changed files with 15 additions and 14 deletions

View file

@ -6328,20 +6328,19 @@ void Application::addAssetToWorldUnzipFailure(QString filePath) {
addAssetToWorldError(filename, "Couldn't unzip file " + filename + "."); addAssetToWorldError(filename, "Couldn't unzip file " + filename + ".");
} }
void Application::addAssetToWorld(QString filePath, QString zipFile, bool isZip, bool isBlocks) { void Application::addAssetToWorld(QString path, QString zipFile, bool isZip, bool isBlocks) {
// Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget(). // Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget().
QString mapping; QString mapping;
QString path = filePath;
QString filename = filenameFromPath(path); QString filename = filenameFromPath(path);
if (isZip) { if (isZip || isBlocks) {
QString assetFolder = zipFile.section("/", -1); QString assetName;
assetFolder.remove(".zip"); if (isZip) {
mapping = "/" + assetFolder + "/" + filename; assetName = zipFile.section("/", -1).remove(".zip");
} else if (isBlocks) { } else if (isBlocks) {
qCDebug(interfaceapp) << "Path to asset folder: " << zipFile; assetName = zipFile.section("/", -1).remove(".zip?noDownload=false");
QString assetFolder = zipFile.section('/', -1); }
assetFolder.remove(".zip?noDownload=false"); QString assetFolder = path.section("model_repo/", -1);
mapping = "/" + assetFolder + "/" + filename; mapping = "/" + assetName + "/" + assetFolder;
} else { } else {
mapping = "/" + filename; mapping = "/" + filename;
} }
@ -6727,8 +6726,10 @@ void Application::handleUnzip(QString zipFile, QStringList unzipFile, bool autoA
if (autoAdd) { if (autoAdd) {
if (!unzipFile.isEmpty()) { if (!unzipFile.isEmpty()) {
for (int i = 0; i < unzipFile.length(); i++) { for (int i = 0; i < unzipFile.length(); i++) {
qCDebug(interfaceapp) << "Preparing file for asset server: " << unzipFile.at(i); if (QFileInfo(unzipFile.at(i)).isFile()) {
addAssetToWorld(unzipFile.at(i), zipFile, isZip, isBlocks); qCDebug(interfaceapp) << "Preparing file for asset server: " << unzipFile.at(i);
addAssetToWorld(unzipFile.at(i), zipFile, isZip, isBlocks);
}
} }
} else { } else {
addAssetToWorldUnzipFailure(zipFile); addAssetToWorldUnzipFailure(zipFile);

View file

@ -55,7 +55,7 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool
QStringList fileList = unzipFile(path, tempDir); QStringList fileList = unzipFile(path, tempDir);
if (!fileList.isEmpty()) { if (!fileList.isEmpty()) {
qCDebug(scriptengine) << "File to upload: " + fileList.first(); qCDebug(scriptengine) << "First file to upload: " + fileList.first();
} else { } else {
qCDebug(scriptengine) << "Unzip failed"; qCDebug(scriptengine) << "Unzip failed";
} }