Replaced chuck with chunk in this code. A minor change.

This commit is contained in:
Julian Harty 2017-08-23 13:41:12 +01:00
parent 1975a7c2f3
commit 3e84659549

View File

@ -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) {