Skip to content

Commit 90a1376

Browse files
committed
Fixed bug #36 reported by @Kubis10
1 parent 0f15484 commit 90a1376

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>me.goral</groupId>
88
<artifactId>KeepMyPassword-Desktop</artifactId>
9-
<version>2.3.2</version>
9+
<version>2.3.3</version>
1010
<name>KeepMyPassword Desktop</name>
1111
<packaging>jar</packaging>
1212

src/main/java/me/goral/keepmypassworddesktop/controllers/MainAppController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ protected void onLoginButtonClick() {
126126
//login
127127
try {
128128
String config = ConfUtil.readConfigFile();
129+
if (config == null) return;
129130
String[] configArr = config.split(":");
130131
String unameFromString = configArr[0];
131132
String encryptedInitial = configArr[1];
@@ -266,6 +267,7 @@ protected void onLoginButtonClick(String unameString, String passwordString) {
266267
//login
267268
try {
268269
String config = ConfUtil.readConfigFile();
270+
if (config == null) return;
269271
String[] configArr = config.split(":");
270272
String unameFromString = configArr[0];
271273
String encryptedInitial = configArr[1];

src/main/java/me/goral/keepmypassworddesktop/util/ConfUtil.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import java.nio.file.Paths;
88
import java.util.Locale;
99

10-
import static me.goral.keepmypassworddesktop.util.AlertsUtil.showErrorDialog;
11-
import static me.goral.keepmypassworddesktop.util.AlertsUtil.showInformationDialog;
1210

1311
public class ConfUtil {
1412

@@ -108,8 +106,14 @@ public static void writeConfFile(String s) {
108106
*/
109107
public static String readConfigFile() {
110108
try {
111-
return Files.readString(Paths.get(workingDirectory + confFileName));
112-
} catch (IOException e){
109+
String confString = Files.readString(Paths.get(workingDirectory + confFileName));
110+
if (confString.isEmpty() ){
111+
deleteConfFiles();
112+
AlertsUtil.showErrorDialog("Error", "Configuration file is empty.", "Deleting account. Please restart program.");
113+
} else {
114+
return confString;
115+
}
116+
} catch (Exception e){
113117
AlertsUtil.showExceptionStackTraceDialog(e);
114118
}
115119
return null;
@@ -121,13 +125,14 @@ public static String readConfigFile() {
121125
public static void deleteConfFiles() {
122126
try {
123127
File f = new File(workingDirectory + confFileName);
124-
if (f.delete()){
125-
File db = new File(workingDirectory + databaseFileName);
126-
if (!db.delete()){
127-
throw new Exception("Database could not be deleted");
128-
}
129-
} else showErrorDialog("Something went wrong", "Whoops!", "Sorry, but something went wrong. " +
130-
"Please, raise an issue on github and describe what happened.");
128+
File db = new File(workingDirectory + databaseFileName);
129+
if (f.exists()){
130+
if (!f.delete()) throw new Exception("Configuration file could not be deleted");
131+
}
132+
if (db.exists()){
133+
if (!db.delete()) throw new Exception("Database could not be deleted");
134+
}
135+
131136
} catch (Exception e){
132137
AlertsUtil.showExceptionStackTraceDialog(e);
133138
}

src/main/resources/me/goral/keepmypassworddesktop/layouts/logged.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
<Button fx:id="genPwd" layoutX="509.0" layoutY="175.0" mnemonicParsing="false" onAction="#onGenPwdClick" prefHeight="25.0" prefWidth="195.0" text="Generate Password" wrapText="true" />
2323
<Button fx:id="showBtn" layoutX="442.0" layoutY="109.0" maxWidth="16" mnemonicParsing="false" onAction="#onShowBtnClick" prefHeight="16" prefWidth="16" />
2424
<Button fx:id="settingsButton" layoutX="625.0" layoutY="5.0" maxHeight="128" maxWidth="128" mnemonicParsing="false" onAction="#onSettingsButtonClick" prefHeight="64" prefWidth="64" />
25-
<Label layoutY="75.0" prefHeight="17.0" prefWidth="750.0" text="v2.3.2" textAlignment="CENTER" />
25+
<Label layoutY="75.0" prefHeight="17.0" prefWidth="750.0" text="v2.3.3" textAlignment="CENTER" />
2626
</children>
2727
</AnchorPane>

0 commit comments

Comments
 (0)