diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index e0c35b7148..e79473783a 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1042,7 +1043,7 @@ bool AssetServer::loadMappingsFromFile() { bool AssetServer::writeMappingsToFile() { auto mapFilePath = _resourcesDirectory.absoluteFilePath(MAP_FILE_NAME); - QFile mapFile { mapFilePath }; + QSaveFile mapFile { mapFilePath }; if (mapFile.open(QIODevice::WriteOnly)) { QJsonObject root; @@ -1053,8 +1054,12 @@ bool AssetServer::writeMappingsToFile() { QJsonDocument jsonDocument { root }; if (mapFile.write(jsonDocument.toJson()) != -1) { - qCDebug(asset_server) << "Wrote JSON mappings to file at" << mapFilePath; - return true; + if (mapFile.commit()) { + qCDebug(asset_server) << "Wrote JSON mappings to file at" << mapFilePath; + return true; + } else { + qCWarning(asset_server) << "Failed to commit JSON mappings to file at" << mapFilePath; + } } else { qCWarning(asset_server) << "Failed to write JSON mappings to file at" << mapFilePath; }