Open Rehckover opened 7 years ago
I get this as well `private void transferData(DownloadRequest request, InputStream in, RandomAccessFile out) { final byte data[] = new byte[BUFFER_SIZE]; long mCurrentBytes = mDownloadedCacheSize; request.setDownloadState(DownloadManager.STATUS_RUNNING); Timber.v("Content Length: " + mContentLength + " for Download Id " + request.getDownloadId()); for (; ; ) { if (request.isCancelled()) { Timber.v(STOPPING_THE_DOWNLOAD_AS_DOWNLOAD_REQUEST_IS_CANCELLED, request.getDownloadId()); request.finish(); updateDownloadFailed(request, DownloadManager.ERROR_DOWNLOAD_CANCELLED, DOWNLOAD_CANCELLED); return; } int bytesRead = readFromResponse(request, data, in);
if (mContentLength != -1 && mContentLength > 0) {
int progress = (int) ((mCurrentBytes * 100) / mContentLength);
updateDownloadProgress(request, progress, mCurrentBytes);
}
if (bytesRead == -1) { // success, end of stream already reached
updateDownloadComplete(request);
return;
} else if (bytesRead == Integer.MIN_VALUE) {
return;
}
if (writeDataToDestination(request, data, bytesRead, out)) {
mCurrentBytes += bytesRead;
} else {
request.finish();
updateDownloadFailed(request, DownloadManager.ERROR_FILE_ERROR, "Failed writing file");
return;
}
}
}`
I think in here we get to bytesRead == -1 somehow. I haven't started debugging this yet but I get this sometimes.
I try to dowload file with size 3.7MB and often receives onComplete while actual file size is 122kb or 50kb. Can you help with this? My link is: https://doc-0g-4k-docs.googleusercontent.com/docs/securesc/f6a1d72cge9p0eq8mkjrughdsskulo18/gqbs46o1bts8v2mn4sv312fk30oavn7s/1503914400000/04284872070643305544/04284872070643305544/0B6e1WFHf4jrKdXFiQ0d6dEZ3WEE?e=download
My code is: