improved naming

This commit is contained in:
Szum123321 2022-12-20 00:46:03 +01:00
parent cffc659001
commit 663089a7a3
5 changed files with 11 additions and 9 deletions

View File

@ -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 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) @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public ErrorHandlingMode errorErrorHandlingMode = ErrorHandlingMode.STRICT; public IntegrityVerificationMode integrityVerificationMode = IntegrityVerificationMode.STRICT;
@Override @Override
public void validatePostLoad() throws ValidationException { public void validatePostLoad() throws ValidationException {
@ -185,7 +185,7 @@ public class ConfigPOJO implements ConfigData {
} }
} }
public enum ErrorHandlingMode { public enum IntegrityVerificationMode {
STRICT, STRICT,
PERMISSIBLE, PERMISSIBLE,
VERY_PERMISSIBLE; VERY_PERMISSIBLE;

View File

@ -30,7 +30,7 @@ import java.util.Optional;
public record CompressionStatus(long treeHash, Map<Path, Exception> brokenFiles, LocalDateTime date, long startTimestamp, long finishTimestamp, String version) implements Serializable { public record CompressionStatus(long treeHash, Map<Path, Exception> brokenFiles, LocalDateTime date, long startTimestamp, long finishTimestamp, String version) implements Serializable {
public static final String DATA_FILENAME = "textile_status.data"; public static final String DATA_FILENAME = "textile_status.data";
public Optional<String> isValid(long hash, RestoreContext ctx) throws RuntimeException { public Optional<String> validate(long hash, RestoreContext ctx) throws RuntimeException {
if(hash != treeHash) if(hash != treeHash)
return Optional.of("Tree Hash mismatch!\n Expected: " + treeHash + ", got: " + hash); return Optional.of("Tree Hash mismatch!\n Expected: " + treeHash + ", got: " + hash);
@ -47,8 +47,10 @@ public record CompressionStatus(long treeHash, Map<Path, Exception> brokenFiles,
return Optional.empty(); return Optional.empty();
} }
public static CompressionStatus readFromFile(Path folder) throws IOException, ClassNotFoundException { public static Path resolveStatusFilename(Path directory) { return directory.resolve(DATA_FILENAME); }
try(InputStream i = Files.newInputStream(folder.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)) { ObjectInputStream obj = new ObjectInputStream(i)) {
return (CompressionStatus) obj.readObject(); return (CompressionStatus) obj.readObject();
} }

View File

@ -112,7 +112,7 @@ public class MakeBackupRunnable implements Callable<Void> {
//ExecutorService swallows exception, so I need to catch everything //ExecutorService swallows exception, so I need to catch everything
log.error("An exception occurred when trying to create new backup file!", e); 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 { try {
Files.delete(outFile); Files.delete(outFile);
} catch (IOException ex) { } catch (IOException ex) {

View File

@ -86,7 +86,7 @@ public abstract class AbstractCompressor {
} catch (IOException e) { } catch (IOException e) {
brokenFileHandler.handle(file, e); brokenFileHandler.handle(file, e);
//In Permissive mode we allow partial backups //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: {}", else log.sendErrorAL(ctx, "An exception occurred while trying to compress: {}",
inputFile.relativize(file).toString(), e inputFile.relativize(file).toString(), e
); );

View File

@ -47,8 +47,8 @@
"text.autoconfig.textile_backup.option.format": "Archive and compression format", "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.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.integrityVerificationMode": "Verify the backup file has not been damaged",
"text.autoconfig.textile_backup.option.errorErrorHandlingMode.@Tooltip": "DO NOT ALTER unless fully certain", "text.autoconfig.textile_backup.option.integrityVerificationMode.@Tooltip": "DO NOT ALTER unless fully certain",
"text.autoconfig.textile_backup.option.permissionLevel": "Min permission level", "text.autoconfig.textile_backup.option.permissionLevel": "Min permission level",