From 52a11c13b8c7394c9c83756b4fde279139895d8c Mon Sep 17 00:00:00 2001 From: Cody Littley <56973212+cody-littley@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:00:08 -0500 Subject: [PATCH] Elegantly handle when an empty PCES is cleared. (#8627) Signed-off-by: Cody Littley --- .../event/preconsensus/PreconsensusEventFileManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/preconsensus/PreconsensusEventFileManager.java b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/preconsensus/PreconsensusEventFileManager.java index ac36ab110c25..e9ce0ce0b48a 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/preconsensus/PreconsensusEventFileManager.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/event/preconsensus/PreconsensusEventFileManager.java @@ -673,7 +673,10 @@ public static void clear( @NonNull final RecycleBin recycleBin, @NonNull final NodeId selfId) { try { - recycleBin.recycle(getDatabaseDirectory(platformContext, selfId)); + final Path path = getDatabaseDirectory(platformContext, selfId); + if (Files.exists(path)) { + recycleBin.recycle(path); + } } catch (final IOException e) { throw new UncheckedIOException("unable to recycle preconsensus event files", e); }