Merge branch 'kunpw-master-patch-10611' into 'master'
Measure http download progress by size of complete file in resumed downloads See merge request fdroid/fdroidclient!923
This commit is contained in:
commit
10a586100e
@ -169,7 +169,7 @@ public abstract class Downloader {
|
|||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
try {
|
try {
|
||||||
bytesRead = 0;
|
bytesRead = outputFile.length();
|
||||||
totalBytes = totalDownloadSize();
|
totalBytes = totalDownloadSize();
|
||||||
byte[] buffer = new byte[bufferSize];
|
byte[] buffer = new byte[bufferSize];
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ public class HttpDownloader extends Downloader {
|
|||||||
private HttpURLConnection connection;
|
private HttpURLConnection connection;
|
||||||
private boolean newFileAvailableOnServer;
|
private boolean newFileAvailableOnServer;
|
||||||
|
|
||||||
|
private long fileFullSize = -1L;
|
||||||
/**
|
/**
|
||||||
* String to append to all HTTP downloads, created in {@link FDroidApp#onCreate()}
|
* String to append to all HTTP downloads, created in {@link FDroidApp#onCreate()}
|
||||||
*/
|
*/
|
||||||
@ -140,6 +141,7 @@ public class HttpDownloader extends Downloader {
|
|||||||
case HttpURLConnection.HTTP_OK:
|
case HttpURLConnection.HTTP_OK:
|
||||||
String headETag = tmpConn.getHeaderField(HEADER_FIELD_ETAG);
|
String headETag = tmpConn.getHeaderField(HEADER_FIELD_ETAG);
|
||||||
contentLength = tmpConn.getContentLength();
|
contentLength = tmpConn.getContentLength();
|
||||||
|
fileFullSize = contentLength;
|
||||||
if (!TextUtils.isEmpty(cacheTag)) {
|
if (!TextUtils.isEmpty(cacheTag)) {
|
||||||
if (cacheTag.equals(headETag)) {
|
if (cacheTag.equals(headETag)) {
|
||||||
Utils.debugLog(TAG, urlString + " cached, not downloading: " + headETag);
|
Utils.debugLog(TAG, urlString + " cached, not downloading: " + headETag);
|
||||||
@ -248,9 +250,9 @@ public class HttpDownloader extends Downloader {
|
|||||||
@TargetApi(24)
|
@TargetApi(24)
|
||||||
public long totalDownloadSize() {
|
public long totalDownloadSize() {
|
||||||
if (Build.VERSION.SDK_INT < 24) {
|
if (Build.VERSION.SDK_INT < 24) {
|
||||||
return connection.getContentLength();
|
return (int) fileFullSize;
|
||||||
} else {
|
} else {
|
||||||
return connection.getContentLengthLong();
|
return fileFullSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user