From c9ea6e7eb6667f3f4b2bd6b1534eea41674d79f5 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 21 Jan 2016 16:45:13 -0800 Subject: [PATCH 1/2] Fix ATP file copy --- assignment-client/src/assets/AssetServer.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index 4416281ab4..90abc2f1bd 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -53,11 +53,16 @@ void AssetServer::run() { const QString RESOURCES_PATH = "assets"; _resourcesDirectory = QDir(ServerPathUtils::getDataDirectory()).filePath(RESOURCES_PATH); - if (!_resourcesDirectory.exists()) { + + bool noExistingAssets = !_resourcesDirectory.exists() \ + || _resourcesDirectory.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files).size() == 0; + + if (noExistingAssets) { qDebug() << "Asset resources directory not found, searching for existing asset resources"; QString oldDataDirectory = QCoreApplication::applicationDirPath(); auto oldResourcesDirectory = QDir(oldDataDirectory).filePath("resources/" + RESOURCES_PATH); + if (QDir(oldResourcesDirectory).exists()) { qDebug() << "Existing assets found in " << oldResourcesDirectory << ", copying to " << _resourcesDirectory; @@ -68,7 +73,15 @@ void AssetServer::run() { resourcesParentDirectory.mkpath("."); } - QFile::copy(oldResourcesDirectory, _resourcesDirectory.absolutePath()); + auto files = QDir(oldResourcesDirectory).entryList(QDir::Files); + + for (auto& file : files) { + auto from = oldResourcesDirectory + QDir::separator() + file; + auto to = _resourcesDirectory.absoluteFilePath(file); + qDebug() << "\tCopying from " << from << " to " << to; + QFile::copy(from, to); + } + } qDebug() << "Creating resources directory"; From 99bb1fcbe1e57740e83f2d2d894990051b8e0f13 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 21 Jan 2016 16:46:45 -0800 Subject: [PATCH 2/2] Remove dirs from atp copy --- assignment-client/src/assets/AssetServer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index 90abc2f1bd..dab3965a6d 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -55,7 +55,7 @@ void AssetServer::run() { _resourcesDirectory = QDir(ServerPathUtils::getDataDirectory()).filePath(RESOURCES_PATH); bool noExistingAssets = !_resourcesDirectory.exists() \ - || _resourcesDirectory.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files).size() == 0; + || _resourcesDirectory.entryList(QDir::Files).size() == 0; if (noExistingAssets) { qDebug() << "Asset resources directory not found, searching for existing asset resources";