Merge pull request #6892 from huffman/fix-asset-migration

Fix ATP file copy
This commit is contained in:
Stephen Birarda 2016-01-21 17:15:46 -08:00
commit 9127edc968

View file

@ -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::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";