From 4ce20242b133b2810a51cc3c3d7a8d38f3476132 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 19 Jan 2016 15:50:45 -0800 Subject: [PATCH] Fix asset server data migration --- assignment-client/src/assets/AssetServer.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index b572f14ba6..c0862e3f63 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -50,17 +50,24 @@ void AssetServer::run() { auto nodeList = DependencyManager::get(); nodeList->addNodeTypeToInterestSet(NodeType::Agent); - const QString OLD_RESOURCES_PATH = "resources/assets"; const QString RESOURCES_PATH = "assets"; - _resourcesDirectory = QDir(ServerPathUtils::getDataFilePath(RESOURCES_PATH)); + _resourcesDirectory = QDir(ServerPathUtils::getDataDirectory()).filePath(RESOURCES_PATH); if (!_resourcesDirectory.exists()) { qDebug() << "Asset resources directory not found, searching for existing asset resources"; QString oldDataDirectory = QCoreApplication::applicationDirPath(); - auto oldResourcesDirectory = QDir(oldDataDirectory).filePath(OLD_RESOURCES_PATH); + auto oldResourcesDirectory = QDir(oldDataDirectory).filePath(RESOURCES_PATH); if (QDir(oldResourcesDirectory).exists()) { qDebug() << "Existing assets found in " << oldResourcesDirectory << ", copying to " << _resourcesDirectory; + + + QDir resourcesParentDirectory = _resourcesDirectory.filePath(".."); + if (!resourcesParentDirectory.exists()) { + qDebug() << "Creating data directory " << resourcesParentDirectory.absolutePath(); + resourcesParentDirectory.mkpath("."); + } + QFile::copy(oldResourcesDirectory, _resourcesDirectory.absolutePath()); }