mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Replaced chuck with chunk in this code. A minor change.
This commit is contained in:
parent
1975a7c2f3
commit
3e84659549
@ -347,14 +347,14 @@ public class DownloadService extends Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create chuck file
|
// Create chunk file
|
||||||
File file = new File(KIWIX_ROOT, chunk.getFileName());
|
File file = new File(KIWIX_ROOT, chunk.getFileName());
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
File fullFile = new File(file.getPath().substring(0, file.getPath().length() - 5));
|
File fullFile = new File(file.getPath().substring(0, file.getPath().length() - 5));
|
||||||
|
|
||||||
long downloaded = Long.parseLong(chunk.getRangeHeader().split("-")[0]);
|
long downloaded = Long.parseLong(chunk.getRangeHeader().split("-")[0]);
|
||||||
if (fullFile.exists() && fullFile.length() == chunk.getSize()) {
|
if (fullFile.exists() && fullFile.length() == chunk.getSize()) {
|
||||||
// Mark chuck status as downloaded
|
// Mark chunk status as downloaded
|
||||||
chunk.isDownloaded = true;
|
chunk.isDownloaded = true;
|
||||||
subscriber.onCompleted();
|
subscriber.onCompleted();
|
||||||
return;
|
return;
|
||||||
@ -384,7 +384,7 @@ public class DownloadService extends Service {
|
|||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
BufferedSource input = null;
|
BufferedSource input = null;
|
||||||
|
|
||||||
// Keep attempting to download chuck despite network errors
|
// Keep attempting to download chunk despite network errors
|
||||||
while (attempts < timeout) {
|
while (attempts < timeout) {
|
||||||
try {
|
try {
|
||||||
String rangeHeader = String.format("%d-%d", downloaded, chunk.getEndByte());
|
String rangeHeader = String.format("%d-%d", downloaded, chunk.getEndByte());
|
||||||
@ -480,7 +480,7 @@ public class DownloadService extends Service {
|
|||||||
} else {
|
} else {
|
||||||
file.renameTo(new File(file.getPath().replace(".part", "")));
|
file.renameTo(new File(file.getPath().replace(".part", "")));
|
||||||
}
|
}
|
||||||
// Mark chuck status as downloaded
|
// Mark chunk status as downloaded
|
||||||
chunk.isDownloaded = true;
|
chunk.isDownloaded = true;
|
||||||
subscriber.onCompleted();
|
subscriber.onCompleted();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user