From 9b24b0c2f748acfec846532eef6fc2b7eb3ce872 Mon Sep 17 00:00:00 2001 From: Marco Bizzarri Date: Mon, 3 Feb 2020 21:46:32 +0000 Subject: [PATCH 1/2] Shows an error message if a non-writeable directory is chosen for downloading a new version Fixes #1231 --- .../java/net/rptools/maptool/client/AppUpdate.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/AppUpdate.java b/src/main/java/net/rptools/maptool/client/AppUpdate.java index 3561a4d7a2..18b762d252 100644 --- a/src/main/java/net/rptools/maptool/client/AppUpdate.java +++ b/src/main/java/net/rptools/maptool/client/AppUpdate.java @@ -21,6 +21,7 @@ import java.util.Properties; import java.util.jar.*; import javax.swing.*; +import net.rptools.maptool.language.I18N; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import okhttp3.OkHttpClient; @@ -228,6 +229,12 @@ private static void downloadFile(URL assetDownloadURL, long assetDownloadSize) { File saveLocation = chooser.getSelectedFile(); + if (!saveLocation.canWrite()) { + String parent = saveLocation.getParent(); + MapTool.showError(I18N.getText("msg.error.directoryNotWriteable", parent)); + return; + } + log.info("URL: " + assetDownloadURL.toString()); log.info("assetDownloadSize: " + assetDownloadSize); @@ -248,9 +255,8 @@ public void run() { pm.setMaximum((int) assetDownloadSize); FileUtils.copyInputStreamToFile(pmis, saveLocation); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); + } catch (IOException ioe) { + MapTool.showError("msg.error.failedSavingNewVersion", ioe); } } }; From b88995fe84aa6fc1b682618075bdfa19607326d6 Mon Sep 17 00:00:00 2001 From: Marco Bizzarri Date: Mon, 3 Feb 2020 21:49:33 +0000 Subject: [PATCH 2/2] Shows an error message if a non-writeable directory is chosen for downloading a new version Adds the required english resources for i18n. Fixes #1231 --- src/main/resources/net/rptools/maptool/language/i18n.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/net/rptools/maptool/language/i18n.properties b/src/main/resources/net/rptools/maptool/language/i18n.properties index d54f07d299..b9eb6db009 100644 --- a/src/main/resources/net/rptools/maptool/language/i18n.properties +++ b/src/main/resources/net/rptools/maptool/language/i18n.properties @@ -1075,6 +1075,8 @@ msg.error.failedSaveCampaign = Could not save campaign. msg.error.failedSaveCampaignOOM = Out of memory while saving campaign!

Try creating a new/empty map and perform the save with that map active. msg.error.failedSaveCampaignPreview = Could not save the campaign preview image. msg.error.failedSaveMap = Could not save map. +msg.error.failedSavingNewVersion = Could not save the new version. +msg.error.directoryNotWriteable = Directory {0} is not writeable. # When the user attempts to save the chat log and we fail, it's an Error. # When we try to autosave the chat log and fail, it's a Warning. # It's all about the semantics, baby. ;-)