From b0e43ad7d2bf5ced9b63dd35cc2029d8c5cfcdef Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Fri, 21 Feb 2025 17:28:15 +0100 Subject: [PATCH] move failCreatingIfExists check to a correct place --- .../main/java/com/usatiuk/kleppmanntree/KleppmannTree.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dhfs-parent/kleppmanntree/src/main/java/com/usatiuk/kleppmanntree/KleppmannTree.java b/dhfs-parent/kleppmanntree/src/main/java/com/usatiuk/kleppmanntree/KleppmannTree.java index 29b3b142..a84091a8 100644 --- a/dhfs-parent/kleppmanntree/src/main/java/com/usatiuk/kleppmanntree/KleppmannTree.java +++ b/dhfs-parent/kleppmanntree/src/main/java/com/usatiuk/kleppmanntree/KleppmannTree.java @@ -344,6 +344,9 @@ public class KleppmannTree, PeerIdT ex var conflictNodeId = newParent.children().get(op.newMeta().getName()); if (conflictNodeId != null) { + if (failCreatingIfExists) + throw new AlreadyExistsException("Already exists: " + op.newMeta().getName() + ": " + conflictNodeId); + var conflictNode = _storage.getById(conflictNodeId); MetaT conflictNodeMeta = conflictNode.meta(); @@ -351,9 +354,6 @@ public class KleppmannTree, PeerIdT ex return new LogRecord<>(op, null); } - if (failCreatingIfExists) - throw new AlreadyExistsException("Already exists: " + op.newMeta().getName() + ": " + conflictNodeId); - String newConflictNodeName = conflictNodeMeta.getName() + ".conflict." + conflictNode.key(); String newOursName = op.newMeta().getName() + ".conflict." + op.childId(); return new LogRecord<>(op, List.of(