MultiThreadDownloader
MultiThreadDownloader copied to clipboard
无法重复下载
下载完成后,再次点击下载,一直显示 xxx is downloading... 进度条也不更新。
找到原因了。
private void dlInit(HttpURLConnection conn, int code) throws Exception {
readResponseHeaders(conn);
DLDBManager.getInstance(context).updateTaskInfo(info);
if (!DLUtil.createFile(info.dirPath, info.fileName))
throw new DLException("Can not create file");
info.file = new File(info.dirPath, info.fileName);
// 如果文件存在则不再下载,这里应该通知用户,现在是毫无反应,这导致无法重复下载同一个文件。
if (info.file.exists() && info.file.length() == info.totalBytes) {
Log.d(TAG, "The file which we want to download was already here.");
return;
}
或者在dlStart里面加一个参数,是否覆盖已有文件。
他这里是判断文件是否存在,你把文件删除了,他也不会再下载了?你的会这样吗