From 240a717ba6e4b5b85b8164875780e3080836fb42 Mon Sep 17 00:00:00 2001 From: Grinderwolf <8948346+Grinderwolf@users.noreply.github.com> Date: Fri, 13 Dec 2019 23:52:52 +0100 Subject: [PATCH] Delete backups from MongoDB when deleting a world (#111) --- .../grinderwolf/swm/plugin/loaders/mongo/MongoLoader.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/slimeworldmanager-plugin/src/main/java/com/grinderwolf/swm/plugin/loaders/mongo/MongoLoader.java b/slimeworldmanager-plugin/src/main/java/com/grinderwolf/swm/plugin/loaders/mongo/MongoLoader.java index ea9b34a4..f57a7100 100644 --- a/slimeworldmanager-plugin/src/main/java/com/grinderwolf/swm/plugin/loaders/mongo/MongoLoader.java +++ b/slimeworldmanager-plugin/src/main/java/com/grinderwolf/swm/plugin/loaders/mongo/MongoLoader.java @@ -273,6 +273,13 @@ public void deleteWorld(String worldName) throws IOException, UnknownWorldExcept bucket.delete(file.getObjectId()); + // Delete backup file + file = bucket.find(Filters.eq("filename", worldName + "_backup")).first(); + + if (file != null) { + bucket.delete(file.getObjectId()); + } + MongoCollection mongoCollection = mongoDatabase.getCollection(collection); mongoCollection.deleteOne(Filters.eq("name", worldName)); } catch (MongoException ex) {