Merge pull request #2646 from kapodamy/yt-deadlock-issue

check if last byte in the block is downloaded
This commit is contained in:
Tobias Groza 2019-10-01 20:44:14 +02:00 committed by GitHub
commit 2a2643641e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -117,7 +117,9 @@ public class DownloadRunnable extends Thread {
byte[] buf = new byte[DownloadMission.BUFFER_SIZE]; byte[] buf = new byte[DownloadMission.BUFFER_SIZE];
int len; int len;
while (start < end && mMission.running && (len = is.read(buf, 0, buf.length)) != -1) { // 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); f.write(buf, 0, len);
start += len; start += len;
block.done += len; block.done += len;