aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-06-02 21:43:50 +0200
committerChristian Schneppe <christian@pix-art.de>2016-06-02 21:43:50 +0200
commit8b483851f1373acdfee029b4b70d0a5b6710517d (patch)
tree289cafb7369fc027a4e813c7b1f77380c69a3ff8 /src
parentf0b82554c5133e0a6c414cd0f104dfa565905ff1 (diff)
parent583aba1b442a1b41a11442d51dc31c5d1f18617e (diff)
Merge remote-tracking branch 'refs/remotes/siacs/master'
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java14
-rw-r--r--src/main/res/values/strings.xml1
2 files changed, 13 insertions, 2 deletions
diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java
index c7d68de16..4ec31c915 100644
--- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java
+++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java
@@ -146,12 +146,18 @@ public class HttpDownloadConnection implements Transferable {
mXmppConnectionService.updateConversationUi();
}
+ private class WriteException extends IOException {
+
+ }
+
private void showToastForException(Exception e) {
e.printStackTrace();
if (e instanceof java.net.UnknownHostException) {
mXmppConnectionService.showErrorToastInUi(R.string.download_failed_server_not_found);
} else if (e instanceof java.net.ConnectException) {
mXmppConnectionService.showErrorToastInUi(R.string.download_failed_could_not_connect);
+ } else if (e instanceof WriteException) {
+ mXmppConnectionService.showErrorToastInUi(R.string.download_failed_could_not_write_file);
} else if (!(e instanceof CancellationException)) {
mXmppConnectionService.showErrorToastInUi(R.string.download_failed_file_not_found);
}
@@ -293,11 +299,15 @@ public class HttpDownloadConnection implements Transferable {
file.createNewFile();
os = AbstractConnectionManager.createOutputStream(file, true);
}
- int count = -1;
+ int count;
byte[] buffer = new byte[1024];
while ((count = is.read(buffer)) != -1) {
transmitted += count;
- os.write(buffer, 0, count);
+ try {
+ os.write(buffer, 0, count);
+ } catch (IOException e) {
+ throw new WriteException();
+ }
updateProgress((int) ((((double) transmitted) / expected) * 100));
if (canceled) {
throw new CancellationException();
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index cdbcccd78..abb363303 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -514,6 +514,7 @@
<string name="download_failed_file_not_found">Download failed: File not found</string>
<string name="download_failed_could_not_connect">Download failed: Could not connect to host</string>
<string name="elv_undo">undo</string>
+ <string name="download_failed_could_not_write_file">Download failed: Could not write file</string>
<string name="pref_use_white_background">Use white background</string>
<string name="pref_use_white_background_summary">Show received messages as black text on a white background</string>
<string name="action_check_update">Check for Updates</string>