FileDownloader icon indicating copy to clipboard operation
FileDownloader copied to clipboard

sofar[17680] not equal total[37111606]问题解决办法进一步请教

Open zhiyong926 opened this issue 6 years ago • 2 comments

问题规律:用户中部分vivo手机,且多为联通宽带下易出现此error回调,部分设备换4G网络后可以正常下载。

Jacksgong前面已经回复同类问题:Occur such exception, because the value of 'content-length' inside the Response-Header is not equal to the real length in the input-stream from the back-end. 并且给出的解决办法是不用管它: For simple way, you can ignore this error by yourself, because when you get the FileDownloader#error callback with this error message, FileDownloader has already completed fetch all data from the network input stream, and FileDownloader will not delete the downloaded file. So if you receive this error message in error callback, you just do some completed thing you want in it.

那么我应该将 TasksManagerDemoActivity.java中的 protected void error(BaseDownloadTask task, Throwable e) { super.error(task, e); final TaskItemViewHolder tag = checkCurrentHolder(task); if (tag == null) { return; } tag.updateNotDownloaded(FileDownloadStatus.error, task.getLargeFileSoFarBytes() , task.getLargeFileTotalBytes()); TasksManager.getImpl().removeTaskForViewHolder(task.getId()); } 改成 protected void error(BaseDownloadTask task, Throwable e) { super.error(task, e); final TaskItemViewHolder tag = checkCurrentHolder(task); if (tag == null) { return; }

         if(e.getMessage().contais("not equal total")){
             return;
         }
            tag.updateNotDownloaded(FileDownloadStatus.error, task.getLargeFileSoFarBytes()
                    , task.getLargeFileTotalBytes());
            TasksManager.getImpl().removeTaskForViewHolder(task.getId());

} 这样就能够解决问题了吗?

zhiyong926 avatar Aug 20 '19 15:08 zhiyong926

应该需要先确认此时 tmp 文件是否是正常的。

rantianhua avatar Aug 31 '19 06:08 rantianhua

这个问题的后续是怎么样的

qyzhaojinxi avatar Jun 03 '20 07:06 qyzhaojinxi