From 53a563937380913b358e545c42293e3ffd3546b2 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Tue, 4 Oct 2022 18:56:48 +0200 Subject: [PATCH] repaired bad error handling --- .../textile_backup/commands/manage/DeleteCommand.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java b/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java index 6fb3ba0..5fc0279 100644 --- a/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java +++ b/src/main/java/net/szum123321/textile_backup/commands/manage/DeleteCommand.java @@ -61,12 +61,9 @@ public class DeleteCommand { Path root = Utilities.getBackupRootPath(Utilities.getLevelName(source.getServer())); RestoreableFile.applyOnFiles(root, Optional.empty(), - e -> { - log.sendError(source, "Couldn't find file by this name."); - log.sendHint(source, "Maybe try /backup list"); - }, + e -> log.sendErrorAL(source, "An exception occurred while trying to delete a file!", e), stream -> stream.filter(f -> f.getCreationTime().equals(dateTime)).map(RestoreableFile::getFile).findFirst() - ).ifPresent(file -> { + ).ifPresentOrElse(file -> { if(Globals.INSTANCE.getLockedFile().filter(p -> p == file).isEmpty()) { try { Files.delete((Path) file); @@ -81,6 +78,9 @@ public class DeleteCommand { log.sendError(source, "Couldn't delete the file because it's being restored right now."); log.sendHint(source, "If you want to abort restoration then use: /backup killR"); } + }, () -> { + log.sendInfo(source, "Couldn't find file by this name."); + log.sendInfo(source, "Maybe try /backup list"); } ); return 0;