From ecb4bfde0beb61675c2a08c96273cce5b551224a Mon Sep 17 00:00:00 2001 From: kapodamy Date: Wed, 18 Sep 2019 16:21:41 -0300 Subject: [PATCH 1/3] check if last byte on block is downloaded --- app/src/main/java/us/shandian/giga/get/DownloadRunnable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java b/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java index 8126cc7e8..a4046bc02 100644 --- a/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java @@ -117,7 +117,7 @@ public class DownloadRunnable extends Thread { byte[] buf = new byte[DownloadMission.BUFFER_SIZE]; int len; - while (start < end && mMission.running && (len = is.read(buf, 0, buf.length)) != -1) { + while (start <= end && mMission.running && (len = is.read(buf, 0, buf.length)) != -1) { f.write(buf, 0, len); start += len; block.done += len; From b1d89175fcd1031d557fe85ba670d85d77cf9827 Mon Sep 17 00:00:00 2001 From: kapodamy Date: Tue, 1 Oct 2019 13:09:26 -0300 Subject: [PATCH 2/3] Update DownloadRunnable.java add description --- app/src/main/java/us/shandian/giga/get/DownloadRunnable.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java b/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java index a4046bc02..9dec6b68a 100644 --- a/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java @@ -117,6 +117,8 @@ public class DownloadRunnable extends Thread { byte[] buf = new byte[DownloadMission.BUFFER_SIZE]; int len; + // use alwways start <= end + // fixes a deadlock in DownloadRunnable because youtube is sending one byte alone after downloading 26MiB exactly while (start <= end && mMission.running && (len = is.read(buf, 0, buf.length)) != -1) { f.write(buf, 0, len); start += len; From 08a081437f2be1e45eaa724661792b83dc17163a Mon Sep 17 00:00:00 2001 From: kapodamy Date: Tue, 1 Oct 2019 15:31:15 -0300 Subject: [PATCH 3/3] Update DownloadRunnable.java --- app/src/main/java/us/shandian/giga/get/DownloadRunnable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java b/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java index 9dec6b68a..f5b9b06d4 100644 --- a/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadRunnable.java @@ -117,7 +117,7 @@ public class DownloadRunnable extends Thread { byte[] buf = new byte[DownloadMission.BUFFER_SIZE]; int len; - // use alwways start <= end + // use always start <= end // fixes a deadlock in DownloadRunnable because youtube is sending one byte alone after downloading 26MiB exactly while (start <= end && mMission.running && (len = is.read(buf, 0, buf.length)) != -1) { f.write(buf, 0, len);