redis: throw error if block request failed

Fixes #3196. Before, we didn't throw an error, and the engine thought the
block isn't occupied. But in fact it might be that redis is still loading,
and the block does exist in the database. The result was a cheesy map.
This commit is contained in:
netinetwalker 2015-09-26 00:26:52 +02:00 committed by est31
parent f062bbd7a1
commit 524a7656e3

@ -118,12 +118,21 @@ std::string Database_Redis::loadBlock(const v3s16 &pos)
freeReplyObject(reply); freeReplyObject(reply);
return str; return str;
} }
case REDIS_REPLY_ERROR: case REDIS_REPLY_ERROR: {
errorstream << "WARNING: loadBlock: loading block " << PP(pos) std::string errstr = reply->str;
<< " failed: " << reply->str << std::endl; freeReplyObject(reply);
errorstream << "loadBlock: loading block " << PP(pos)
<< " failed: " << errstr << std::endl;
throw FileNotGoodException(std::string(
"Redis command 'HGET %s %s' errored: ") + errstr);
} }
}
errorstream << "loadBlock: loading block " << PP(pos)
<< " returned invalid reply type " << reply->type
<< ": " << reply->str << std::endl;
freeReplyObject(reply); freeReplyObject(reply);
return ""; throw FileNotGoodException(std::string(
"Redis command 'HGET %s %s' gave invalid reply."));
} }
bool Database_Redis::deleteBlock(const v3s16 &pos) bool Database_Redis::deleteBlock(const v3s16 &pos)