diff --git a/src/main/java/net/rptools/maptool/client/ui/players/PlayerDatabaseDialogController.java b/src/main/java/net/rptools/maptool/client/ui/players/PlayerDatabaseDialogController.java index a43d99b7eb..7c53942358 100644 --- a/src/main/java/net/rptools/maptool/client/ui/players/PlayerDatabaseDialogController.java +++ b/src/main/java/net/rptools/maptool/client/ui/players/PlayerDatabaseDialogController.java @@ -212,7 +212,7 @@ public void close() { | InvalidKeySpecException | PasswordDatabaseException | InvalidKeyException e) { - MapTool.showError("playerDB.dialog.error.undoingChanges", e); + MapTool.showError("playerDB.dialog.error.savingChanges", e); } ; Players.removePropertyChangeListener(changeListener); diff --git a/src/main/java/net/rptools/maptool/model/player/PasswordFilePlayerDatabase.java b/src/main/java/net/rptools/maptool/model/player/PasswordFilePlayerDatabase.java index fe781ba15e..db50a23f3e 100644 --- a/src/main/java/net/rptools/maptool/model/player/PasswordFilePlayerDatabase.java +++ b/src/main/java/net/rptools/maptool/model/player/PasswordFilePlayerDatabase.java @@ -218,7 +218,7 @@ private Map readPasswordFile(File file) } return players; } catch (IOException ioe) { - throw new PasswordDatabaseException("msg.err.passFile.errorReadingFile", ioe); + throw new PasswordDatabaseException("msg.error.passFile.errorReadingFile", ioe); } } finally { passwordFileLock.unlock(); @@ -233,7 +233,9 @@ private void writePasswordFile() throws PasswordDatabaseException { if (dirty.compareAndSet(true, false)) { try { - Files.copy(passwordFile.toPath(), backupPasswordFile.toPath(), REPLACE_EXISTING); + if (passwordFile.exists()) { + Files.copy(passwordFile.toPath(), backupPasswordFile.toPath(), REPLACE_EXISTING); + } } catch (IOException ioe) { String msg = I18N.getText("msg.err.passFile.errorCopyingBackup"); log.error(msg, ioe); @@ -293,6 +295,16 @@ private void writePasswordFile() throws PasswordDatabaseException { private void writePublicKeys(PlayerDetails playerDetails) throws IOException { try { passwordFileLock.lock(); + File keyDir = passwordFile.getParentFile().toPath().resolve(PUBLIC_KEY_DIR).toFile(); + if (!keyDir.exists()) { + keyDir.mkdirs(); + } + File keyBackupDir = + passwordFile.getParentFile().toPath().resolve(PUBLIC_KEY_DIR).resolve("backup").toFile(); + if (!keyBackupDir.exists()) { + keyBackupDir.mkdirs(); + } + Set publicKeyDetails = playerDetails.publicKeyDetails(); // First get all the public keys files with a public key marked dirty @@ -550,8 +562,8 @@ public void commitChanges() removeOldPublicKeys(); savedDetails.clear(); savedDetails.putAll(playerDetails); - dirty.set(true); } + dirty.set(true); writePasswordFile(); } diff --git a/src/main/resources/net/rptools/maptool/language/i18n.properties b/src/main/resources/net/rptools/maptool/language/i18n.properties index 4898580741..f9d206644f 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n.properties @@ -2546,8 +2546,7 @@ playerDB.dialog.error.passwordTooShort = Password is too short playerDB.dialog.error.invalidPublicKey = Invalid Public Key playerDB.dialog.error.emptyBlockReason = Blocked reason can not be empty playerDB.dialog.error.playerExists = Player already exists -playerDB.dialog.error.undoingChanges = Error Unding database changes - +playerDB.dialog.error.savingChanges = Error saving database changes # Text to display instead of the password playerDB.dialog.encodedPassword = -- Encoded Password --