aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-07-09 21:35:26 +0200
committerChristian Schneppe <christian@pix-art.de>2018-07-09 21:35:26 +0200
commited2334ae0bbfd84da88bf17dba4fccc7770f5853 (patch)
treea14e4c0c1c734d46adbcf23c08b6a380be087834 /src/main
parent80f0627da7824cb4203993e5a72e4202076d4df4 (diff)
automatically start download if file size is known
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
index b35e0aa83..efdfdc61e 100644
--- a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
+++ b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
@@ -52,7 +52,7 @@ public class HttpDownloadConnection implements Transferable {
private final SimpleDateFormat fileDateFormat = new SimpleDateFormat("yyyyMMdd_HHmmssSSS", Locale.US);
- public HttpDownloadConnection(HttpConnectionManager manager) {
+ HttpDownloadConnection(HttpConnectionManager manager) {
this.mHttpConnectionManager = manager;
this.mXmppConnectionService = manager.getXmppConnectionService();
this.mUseTor = mXmppConnectionService.useTorToConnect();
@@ -64,7 +64,7 @@ public class HttpDownloadConnection implements Transferable {
if (this.mStatus == STATUS_OFFER_CHECK_FILESIZE) {
checkFileSize(true);
} else {
- new Thread(new FileDownloader(true)).start();
+ download(true);
}
return true;
} else {
@@ -113,12 +113,22 @@ public class HttpDownloadConnection implements Transferable {
this.message.setEncryption(Message.ENCRYPTION_NONE);
}
method = mUrl.getProtocol().equalsIgnoreCase(P1S3UrlStreamHandler.PROTOCOL_NAME) ? Method.P1_S3 : Method.HTTP_UPLOAD;
- checkFileSize(interactive);
+ long knownFileSize = message.getFileParams().size;
+ if (knownFileSize > 0 && interactive && method != Method.P1_S3) {
+ this.file.setExpectedSize(knownFileSize);
+ download(true);
+ } else {
+ checkFileSize(interactive);
+ }
} catch (MalformedURLException e) {
this.cancel();
}
}
+ private void download(boolean interactive) {
+ new Thread(new FileDownloader(interactive)).start();
+ }
+
private void checkFileSize(boolean interactive) {
new Thread(new FileSizeChecker(interactive)).start();
}
@@ -257,7 +267,7 @@ public class HttpDownloadConnection implements Transferable {
&& size <= mHttpConnectionManager.getAutoAcceptFileSize()
&& mXmppConnectionService.isDataSaverDisabled()) {
HttpDownloadConnection.this.acceptedAutomatically = true;
- new Thread(new FileDownloader(interactive)).start();
+ download(interactive);
} else {
changeStatus(STATUS_OFFER);
HttpDownloadConnection.this.acceptedAutomatically = false;