Run a sync task after completing a bulk update (#579)

This commit is contained in:
Luck 2017-12-01 17:44:32 +00:00
parent 800749c5ed
commit 0d9034504e
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 11 additions and 8 deletions

View File

@ -72,13 +72,14 @@ public class BulkUpdateCommand extends SingleCommand {
}
Message.BULK_UPDATE_STARTING.send(sender);
plugin.getStorage().applyBulkUpdate(operation).thenAccept(b -> {
plugin.getStorage().applyBulkUpdate(operation).thenAcceptAsync(b -> {
if (b) {
plugin.getUpdateTaskBuffer().requestDirectly();
Message.BULK_UPDATE_SUCCESS.send(sender);
} else {
Message.BULK_UPDATE_FAILURE.send(sender);
}
});
}, plugin.getScheduler().async());
return CommandResult.SUCCESS;
}

View File

@ -228,7 +228,8 @@ public class MongoDao extends AbstractDao {
.map(MongoDao::nodeToDoc)
.collect(Collectors.toList());
c.replaceOne(new Document("_id", uuid), d.append("permissions", newNodes));
d.append("permissions", newNodes).remove("perms");
c.replaceOne(new Document("_id", uuid), d);
}
}
}
@ -252,7 +253,8 @@ public class MongoDao extends AbstractDao {
.map(MongoDao::nodeToDoc)
.collect(Collectors.toList());
c.replaceOne(new Document("_id", holder), d.append("permissions", newNodes));
d.append("permissions", newNodes).remove("perms");
c.replaceOne(new Document("_id", holder), d);
}
}
}

View File

@ -80,15 +80,15 @@ public class WebEditorUtils {
}
public static PermissionHolder getHolderFromIdentifier(LuckPermsPlugin plugin, Sender sender, String who) {
if (who.startsWith("group/")) {
String group = who.substring("group/".length());
if (who.startsWith(GROUP_ID_PATTERN)) {
String group = who.substring(GROUP_ID_PATTERN.length());
Group holder = plugin.getGroupManager().getIfLoaded(group);
if (holder == null) {
Message.APPLY_EDITS_TARGET_GROUP_NOT_EXISTS.send(sender, group);
}
return holder;
} else if (who.startsWith("user/")) {
String user = who.substring("user/".length());
} else if (who.startsWith(USER_ID_PATTERN)) {
String user = who.substring(USER_ID_PATTERN.length());
UUID uuid = CommandUtils.parseUuid(user);
if (uuid == null) {
Message.APPLY_EDITS_TARGET_USER_NOT_UUID.send(sender, user);