From 663089a7a3a6e661d6fb2bbcd25a7d7636701d4d Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Tue, 20 Dec 2022 00:46:03 +0100 Subject: [PATCH] improved naming --- .../net/szum123321/textile_backup/config/ConfigPOJO.java | 4 ++-- .../szum123321/textile_backup/core/CompressionStatus.java | 8 +++++--- .../textile_backup/core/create/MakeBackupRunnable.java | 2 +- .../core/create/compressors/AbstractCompressor.java | 2 +- src/main/resources/assets/textile_backup/lang/en_us.json | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java b/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java index 4cbc4b3..f13f2da 100644 --- a/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java +++ b/src/main/java/net/szum123321/textile_backup/config/ConfigPOJO.java @@ -168,7 +168,7 @@ public class ConfigPOJO implements ConfigData { Very Permissible mode will skip the verification process. THIS MOST CERTAINLY WILL LEAD TO DATA LOSS OR CORRUPTION """) @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) - public ErrorHandlingMode errorErrorHandlingMode = ErrorHandlingMode.STRICT; + public IntegrityVerificationMode integrityVerificationMode = IntegrityVerificationMode.STRICT; @Override public void validatePostLoad() throws ValidationException { @@ -185,7 +185,7 @@ public class ConfigPOJO implements ConfigData { } } - public enum ErrorHandlingMode { + public enum IntegrityVerificationMode { STRICT, PERMISSIBLE, VERY_PERMISSIBLE; diff --git a/src/main/java/net/szum123321/textile_backup/core/CompressionStatus.java b/src/main/java/net/szum123321/textile_backup/core/CompressionStatus.java index e97831b..fa1ffbe 100644 --- a/src/main/java/net/szum123321/textile_backup/core/CompressionStatus.java +++ b/src/main/java/net/szum123321/textile_backup/core/CompressionStatus.java @@ -30,7 +30,7 @@ import java.util.Optional; public record CompressionStatus(long treeHash, Map brokenFiles, LocalDateTime date, long startTimestamp, long finishTimestamp, String version) implements Serializable { public static final String DATA_FILENAME = "textile_status.data"; - public Optional isValid(long hash, RestoreContext ctx) throws RuntimeException { + public Optional validate(long hash, RestoreContext ctx) throws RuntimeException { if(hash != treeHash) return Optional.of("Tree Hash mismatch!\n Expected: " + treeHash + ", got: " + hash); @@ -47,8 +47,10 @@ public record CompressionStatus(long treeHash, Map brokenFiles, return Optional.empty(); } - public static CompressionStatus readFromFile(Path folder) throws IOException, ClassNotFoundException { - try(InputStream i = Files.newInputStream(folder.resolve(DATA_FILENAME)); + public static Path resolveStatusFilename(Path directory) { return directory.resolve(DATA_FILENAME); } + + public static CompressionStatus readFromFile(Path directory) throws IOException, ClassNotFoundException { + try(InputStream i = Files.newInputStream(directory.resolve(DATA_FILENAME)); ObjectInputStream obj = new ObjectInputStream(i)) { return (CompressionStatus) obj.readObject(); } diff --git a/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java b/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java index d0bbb8d..13553a4 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/MakeBackupRunnable.java @@ -112,7 +112,7 @@ public class MakeBackupRunnable implements Callable { //ExecutorService swallows exception, so I need to catch everything log.error("An exception occurred when trying to create new backup file!", e); - if (ConfigHelper.INSTANCE.get().errorErrorHandlingMode.isStrict()) { + if (ConfigHelper.INSTANCE.get().integrityVerificationMode.isStrict()) { try { Files.delete(outFile); } catch (IOException ex) { diff --git a/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java b/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java index 65bf00a..c50c1d3 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java @@ -86,7 +86,7 @@ public abstract class AbstractCompressor { } catch (IOException e) { brokenFileHandler.handle(file, e); //In Permissive mode we allow partial backups - if(ConfigHelper.INSTANCE.get().errorErrorHandlingMode.isStrict()) throw e; + if (ConfigHelper.INSTANCE.get().integrityVerificationMode.isStrict()) throw e; else log.sendErrorAL(ctx, "An exception occurred while trying to compress: {}", inputFile.relativize(file).toString(), e ); diff --git a/src/main/resources/assets/textile_backup/lang/en_us.json b/src/main/resources/assets/textile_backup/lang/en_us.json index 0c9ae5e..9846353 100644 --- a/src/main/resources/assets/textile_backup/lang/en_us.json +++ b/src/main/resources/assets/textile_backup/lang/en_us.json @@ -47,8 +47,8 @@ "text.autoconfig.textile_backup.option.format": "Archive and compression format", "text.autoconfig.textile_backup.option.format.@Tooltip": "See: https://github.com/Szum123321/textile_backup/wiki/Configuration#format", - "text.autoconfig.textile_backup.option.errorErrorHandlingMode": "Compression error handling mode", - "text.autoconfig.textile_backup.option.errorErrorHandlingMode.@Tooltip": "DO NOT ALTER unless fully certain", + "text.autoconfig.textile_backup.option.integrityVerificationMode": "Verify the backup file has not been damaged", + "text.autoconfig.textile_backup.option.integrityVerificationMode.@Tooltip": "DO NOT ALTER unless fully certain", "text.autoconfig.textile_backup.option.permissionLevel": "Min permission level",