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); Message.BULK_UPDATE_STARTING.send(sender);
plugin.getStorage().applyBulkUpdate(operation).thenAccept(b -> { plugin.getStorage().applyBulkUpdate(operation).thenAcceptAsync(b -> {
if (b) { if (b) {
plugin.getUpdateTaskBuffer().requestDirectly();
Message.BULK_UPDATE_SUCCESS.send(sender); Message.BULK_UPDATE_SUCCESS.send(sender);
} else { } else {
Message.BULK_UPDATE_FAILURE.send(sender); Message.BULK_UPDATE_FAILURE.send(sender);
} }
}); }, plugin.getScheduler().async());
return CommandResult.SUCCESS; return CommandResult.SUCCESS;
} }

View File

@ -228,7 +228,8 @@ public class MongoDao extends AbstractDao {
.map(MongoDao::nodeToDoc) .map(MongoDao::nodeToDoc)
.collect(Collectors.toList()); .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) .map(MongoDao::nodeToDoc)
.collect(Collectors.toList()); .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) { public static PermissionHolder getHolderFromIdentifier(LuckPermsPlugin plugin, Sender sender, String who) {
if (who.startsWith("group/")) { if (who.startsWith(GROUP_ID_PATTERN)) {
String group = who.substring("group/".length()); String group = who.substring(GROUP_ID_PATTERN.length());
Group holder = plugin.getGroupManager().getIfLoaded(group); Group holder = plugin.getGroupManager().getIfLoaded(group);
if (holder == null) { if (holder == null) {
Message.APPLY_EDITS_TARGET_GROUP_NOT_EXISTS.send(sender, group); Message.APPLY_EDITS_TARGET_GROUP_NOT_EXISTS.send(sender, group);
} }
return holder; return holder;
} else if (who.startsWith("user/")) { } else if (who.startsWith(USER_ID_PATTERN)) {
String user = who.substring("user/".length()); String user = who.substring(USER_ID_PATTERN.length());
UUID uuid = CommandUtils.parseUuid(user); UUID uuid = CommandUtils.parseUuid(user);
if (uuid == null) { if (uuid == null) {
Message.APPLY_EDITS_TARGET_USER_NOT_UUID.send(sender, user); Message.APPLY_EDITS_TARGET_USER_NOT_UUID.send(sender, user);