feat: v0.5.1, fix open blank window when decrypt fails

This commit is contained in:
2022-04-17 18:49:17 +08:00
parent e9d97a09b9
commit 33aea5ae59
2 changed files with 5 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
package me.hatter.tools.tinyencrypt.config; package me.hatter.tools.tinyencrypt.config;
public class TinyEncryptConstant { public class TinyEncryptConstant {
public static final String VERSION = "0.5.0"; public static final String VERSION = "0.5.1";
public static final String ENC_FILE_EXT = ".tinyenc"; public static final String ENC_FILE_EXT = ".tinyenc";
} }

View File

@@ -112,7 +112,10 @@ public class EncryptedFileUtil {
public static void decryptInWindow(TinyEncryptConfig config, File file, boolean pgp, boolean editable) { public static void decryptInWindow(TinyEncryptConfig config, File file, boolean pgp, boolean editable) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
AtomicReference<TinyEncryptMeta> metaRef = new AtomicReference<>(); AtomicReference<TinyEncryptMeta> metaRef = new AtomicReference<>();
decryptToOutputStream(config, file, baos, pgp, metaRef); boolean decryptSuccess = decryptToOutputStream(config, file, baos, pgp, metaRef);
if (!decryptSuccess) {
return;
}
String decrypted = new String(baos.toByteArray(), StandardCharsets.UTF_8); String decrypted = new String(baos.toByteArray(), StandardCharsets.UTF_8);
String editResult = SwingWindow.create((editable ? "Edit" : "View") + " file: " + file.getName()) String editResult = SwingWindow.create((editable ? "Edit" : "View") + " file: " + file.getName())