mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 03:25:19 +01:00
Fix duplicate UUID delete with Mongo storage (#3777)
This commit is contained in:
parent
84fce987d5
commit
f999f9f234
@ -549,7 +549,7 @@ public class MongoStorage implements StorageImplementation {
|
||||
|
||||
if (!conflicting.isEmpty()) {
|
||||
// remove the mappings for conflicting uuids
|
||||
c.deleteMany(Filters.and(conflicting.stream().map(u -> Filters.eq("_id", u)).collect(Collectors.toList())));
|
||||
c.deleteMany(Filters.or(conflicting.stream().map(u -> Filters.eq("_id", u)).collect(Collectors.toList())));
|
||||
result = result.withOtherUuidsPresent(conflicting);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ import me.lucko.luckperms.standalone.utils.TestPluginBootstrap.TestPlugin;
|
||||
import me.lucko.luckperms.standalone.utils.TestPluginProvider;
|
||||
import net.luckperms.api.actionlog.Action;
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
import net.luckperms.api.model.PlayerSaveResult;
|
||||
import net.luckperms.api.model.PlayerSaveResult.Outcome;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
@ -139,7 +141,12 @@ public class StorageIntegrationTest {
|
||||
// try to create / save a user
|
||||
UUID exampleUniqueId = UUID.fromString("c1d60c50-70b5-4722-8057-87767557e50d");
|
||||
String exampleUsername = "Luck";
|
||||
plugin.getStorage().savePlayerData(exampleUniqueId, exampleUsername).join();
|
||||
|
||||
PlayerSaveResult saveResult = plugin.getStorage().savePlayerData(exampleUniqueId, exampleUsername).join();
|
||||
assertEquals(ImmutableSet.of(Outcome.CLEAN_INSERT), saveResult.getOutcomes());
|
||||
assertNull(saveResult.getOtherUniqueIds());
|
||||
assertNull(saveResult.getPreviousUsername());
|
||||
|
||||
User user = plugin.getStorage().loadUser(exampleUniqueId, exampleUsername).join();
|
||||
user.setNode(DataType.NORMAL, TEST_PERMISSION_1, true);
|
||||
user.setNode(DataType.NORMAL, TEST_PERMISSION_2, true);
|
||||
@ -217,6 +224,27 @@ public class StorageIntegrationTest {
|
||||
assertNull(plugin.getStorage().getPlayerName(otherExampleUniqueId).join());
|
||||
assertNull(plugin.getStorage().getPlayerUniqueId("example").join());
|
||||
assertNull(plugin.getStorage().getPlayerName(UUID.randomUUID()).join());
|
||||
|
||||
|
||||
// test savePlayerData
|
||||
saveResult = plugin.getStorage().savePlayerData(exampleUniqueId, exampleUsername).join();
|
||||
assertEquals(ImmutableSet.of(Outcome.NO_CHANGE), saveResult.getOutcomes());
|
||||
assertNull(saveResult.getOtherUniqueIds());
|
||||
assertNull(saveResult.getPreviousUsername());
|
||||
|
||||
saveResult = plugin.getStorage().savePlayerData(exampleUniqueId, "test").join();
|
||||
assertEquals(ImmutableSet.of(Outcome.USERNAME_UPDATED), saveResult.getOutcomes());
|
||||
assertNull(saveResult.getOtherUniqueIds());
|
||||
assertTrue(exampleUsername.equalsIgnoreCase(saveResult.getPreviousUsername()));
|
||||
assertNull(plugin.getStorage().getPlayerUniqueId(exampleUsername).join());
|
||||
assertTrue("test".equalsIgnoreCase(plugin.getStorage().getPlayerName(exampleUniqueId).join()));
|
||||
|
||||
saveResult = plugin.getStorage().savePlayerData(otherExampleUniqueId, "test").join();
|
||||
assertEquals(ImmutableSet.of(Outcome.CLEAN_INSERT, Outcome.OTHER_UNIQUE_IDS_PRESENT_FOR_USERNAME), saveResult.getOutcomes());
|
||||
assertEquals(ImmutableSet.of(exampleUniqueId), saveResult.getOtherUniqueIds());
|
||||
assertNull(saveResult.getPreviousUsername());
|
||||
assertEquals(otherExampleUniqueId, plugin.getStorage().getPlayerUniqueId("test").join());
|
||||
assertNull(plugin.getStorage().getPlayerName(exampleUniqueId).join());
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
Loading…
Reference in New Issue
Block a user