From 568a4b0a2e08af0e6a6e2afdced0f440d19bad7e Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 19 Sep 2023 22:05:19 -0500 Subject: [PATCH] Improve FileUtil.renameCorruptedFile() messages --- .../distanthorizons/core/util/FileUtil.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/util/FileUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/util/FileUtil.java index d311e1432..26ab91db4 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/util/FileUtil.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/util/FileUtil.java @@ -49,17 +49,24 @@ public class FileUtil } - if (file.renameTo(corruptedFile)) + if (file.exists()) { - LOGGER.error("Renamed corrupted file to [" + corruptedFileName + "]."); + if (file.renameTo(corruptedFile)) + { + LOGGER.error("Renamed corrupted file to [" + corruptedFileName + "]."); + } + else + { + LOGGER.error("Failed to rename corrupted file to [" + corruptedFileName + "]. Attempting to delete file..."); + if (!file.delete()) + { + LOGGER.error("Unable to delete corrupted file [" + corruptedFileName + "]."); + } + } } else { - LOGGER.error("Failed to rename corrupted file to [" + corruptedFileName + "]. Attempting to delete file..."); - if (!file.delete()) - { - LOGGER.error("Unable to delete corrupted file [" + corruptedFileName + "]."); - } + LOGGER.error("Corrupted file [" + file + "] doesn't exist."); } return corruptedFile;