1.apk 安装过程中重启apk未安装未删除安装包修改为继续安装并删除安装包

2.apk 安装过程中重启apk已安装未删除安装包修改为删除安装包
3.DownLoadManager撤回下载任务但文件丢失会产生-tmp 0 size大小文件bug,下载异常日志打印
This commit is contained in:
2025-11-10 16:42:17 +08:00
parent 646719c3fb
commit 632000cb56
4 changed files with 55 additions and 14 deletions

View File

@@ -143,7 +143,9 @@ public class DownLoadManeger {
TaskQueue.getInstance().add(new DownLoadTaskThread(downLoadTaskBean, observer));
}
}
if(!file.exists()&&downLoadTaskBean.getCurrentProgress()==0){
LogUtils.loge("power down but downloadstaskbean table remain task");
}
}
}
}
@@ -156,13 +158,6 @@ public class DownLoadManeger {
if(file.exists()&&file.length()>0&&file.length()<=downLoadTaskBean.getTotal()){
downLoadTaskBean.setCurrentProgress(file.length());
DaoManager.getInstance().update(DownLoadTaskBean.class,downLoadTaskBean);
}else if(!file.exists()){
try {
boolean createFileSuccess=file.createNewFile();
LogUtils.loge("下载任务但文件丢失创建文件="+createFileSuccess);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}else if(downLoadTaskBean.getCurrentProgress()!=0&&!TextUtils.isEmpty(downLoadTaskBean.getUrl())&&!TextUtils.isEmpty(downLoadTaskBean.getFileName())&&!TextUtils.isEmpty(downLoadTaskBean.getPath())){
File file = new File(downLoadTaskBean.getPath()+downLoadTaskBean.getFileName()+"-tmp");

View File

@@ -64,9 +64,9 @@ public class DownLoadTaskThread implements Runnable {
if(currentTotal==bean.getTotal()){
File targFile = new File(bean.getPath(), bean.getFileName());
file.renameTo(targFile);//重命名
Thread.sleep(5000);
file.delete();//删除临时文件
Thread.sleep(3000);
observer.onFinish(bean, bean.getTaskId(), currentTotal);
file.delete();//删除临时文件
return;
}
//设置下载位置
@@ -115,10 +115,10 @@ public class DownLoadTaskThread implements Runnable {
LogUtils.loge("download Exception===>sleeping before");
File targFile = new File(bean.getPath(), bean.getFileName());
file.renameTo(targFile);//重命名
Thread.sleep(5000);
file.delete();//删除临时文件
Thread.sleep(3000);
LogUtils.loge("download Exception===>sleeping after");
observer.onFinish(bean, bean.getTaskId(), currentTotal);
file.delete();//删除临时文件
}else {
LogUtils.loge("下载失败");
if (observer != null) {