don't perform asset cleanup if mapping file load fails

This commit is contained in:
Stephen Birarda 2016-04-11 17:14:31 -07:00
parent 334dc3cb6c
commit 026f58c866
2 changed files with 22 additions and 14 deletions

View file

@ -122,8 +122,7 @@ void AssetServer::completeSetup() {
}
// load whatever mappings we currently have from the local file
loadMappingsFromFile();
if (loadMappingsFromFile()) {
qInfo() << "Serving files from: " << _filesDirectory.path();
// Check the asset directory to output some information about what we have
@ -134,9 +133,16 @@ void AssetServer::completeSetup() {
qInfo() << "There are" << hashedFiles.size() << "asset files in the asset directory.";
if (_fileMappings.count() > 0) {
cleanupUnmappedFiles();
}
nodeList->addNodeTypeToInterestSet(NodeType::Agent);
} else {
qCritical() << "Asset Server assignment will not continue because mapping file could not be loaded.";
setFinished(true);
}
}
void AssetServer::cleanupUnmappedFiles() {
@ -427,7 +433,7 @@ void AssetServer::sendStatsPacket() {
static const QString MAP_FILE_NAME = "map.json";
void AssetServer::loadMappingsFromFile() {
bool AssetServer::loadMappingsFromFile() {
auto mapFilePath = _resourcesDirectory.absoluteFilePath(MAP_FILE_NAME);
@ -464,15 +470,17 @@ void AssetServer::loadMappingsFromFile() {
}
qInfo() << "Loaded" << _fileMappings.count() << "mappings from map file at" << mapFilePath;
return;
return true;
}
}
qCritical() << "Failed to read mapping file at" << mapFilePath << "- assignment will not continue.";
setFinished(true);
qCritical() << "Failed to read mapping file at" << mapFilePath;
return false;
} else {
qInfo() << "No existing mappings loaded from file since no file was found at" << mapFilePath;
}
return true;
}
bool AssetServer::writeMappingsToFile() {

View file

@ -48,7 +48,7 @@ private:
void handleRenameMappingOperation(ReceivedMessage& message, SharedNodePointer senderNode, NLPacketList& replyPacket);
// Mapping file operations must be called from main assignment thread only
void loadMappingsFromFile();
bool loadMappingsFromFile();
bool writeMappingsToFile();
/// Set the mapping for path to hash