Fix MongoDao issue causing unnecessary writes each time a user is loaded (#589)

This commit is contained in:
Luck 2017-12-07 16:52:09 +00:00
parent 90cbff885f
commit 2baea0ce13
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -277,11 +277,12 @@ public class MongoDao extends AbstractDao {
// User exists, let's load.
Document d = cursor.next();
String name = d.getString("name");
user.getPrimaryGroup().setStoredValue(d.getString("primaryGroup"));
user.setName(d.getString("name"), true);
Set<Node> nodes = nodesFromDoc(d).stream().map(NodeModel::toNode).collect(Collectors.toSet());
user.setEnduringNodes(nodes);
user.setName(name, true);
boolean save = plugin.getUserManager().giveDefaultIfNeeded(user, false);
if (user.getName().isPresent() && (name == null || !user.getName().get().equalsIgnoreCase(name))) {