Fix asset server data migration

This commit is contained in:
Ryan Huffman 2016-01-19 15:50:45 -08:00
parent 37cfac404e
commit 4ce20242b1

View file

@ -50,17 +50,24 @@ void AssetServer::run() {
auto nodeList = DependencyManager::get<NodeList>();
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());
}