|
@@ -107,12 +107,11 @@ public class VideoDownloader {
|
|
|
byte[] buffer = new byte[1024 * 1024];
|
|
|
long lastReadTime = System.currentTimeMillis();
|
|
|
int bytesRead;
|
|
|
+ int downloadLength = 0;
|
|
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
|
|
+ downloadLength += bytesRead;
|
|
|
outputStream.write(buffer, 0, bytesRead);
|
|
|
- lastReadTime = System.currentTimeMillis();
|
|
|
- // 检查是否长时间没有读取到新数据
|
|
|
- if (System.currentTimeMillis() - lastReadTime > READ_TIMEOUT_SECONDS * 1000) {
|
|
|
- log.error("No data read for a long time, aborting download.");
|
|
|
+ if (expectedSize == downloadLength) {
|
|
|
break;
|
|
|
}
|
|
|
}
|