fix bug https://github.com/AriaLyy/Aria/issues/505 增加上传任务强制上传的功能
This commit is contained in:
@@ -19,6 +19,7 @@ package com.arialyy.aria.util;
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.inf.IRecordHandler;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.orm.DbEntity;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
@@ -37,7 +38,7 @@ public class CheckUtil {
|
||||
* @param filePath 文件保存路径
|
||||
* @return false 任务不再执行,true 任务继续执行
|
||||
*/
|
||||
public static boolean checkAndHandlePathConflicts(boolean isForceDownload, String filePath) {
|
||||
public static boolean checkDownloadPathConflicts(boolean isForceDownload, String filePath) {
|
||||
if (DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=?", filePath)) {
|
||||
if (!isForceDownload) {
|
||||
ALog.e(TAG, String.format("下载失败,保存路径【%s】已经被其它任务占用,请设置其它保存路径", filePath));
|
||||
@@ -51,6 +52,27 @@ public class CheckUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查和处理路径冲突
|
||||
*
|
||||
* @param isForceUpload true,如果路径冲突,将删除其它任务的记录的
|
||||
* @param filePath 文件保存路径
|
||||
* @return false 任务不再执行,true 任务继续执行
|
||||
*/
|
||||
public static boolean checkUploadPathConflicts(boolean isForceUpload, String filePath) {
|
||||
if (DbEntity.checkDataExist(UploadEntity.class, "filePath=?", filePath)) {
|
||||
if (!isForceUpload) {
|
||||
ALog.e(TAG, String.format("上传失败,文件路径【%s】已经被其它任务占用,请设置其它保存路径", filePath));
|
||||
return false;
|
||||
} else {
|
||||
ALog.w(TAG, String.format("文件路径【%s】已经被其它任务占用,当前任务将覆盖该路径的文件", filePath));
|
||||
RecordUtil.delTaskRecord(filePath, IRecordHandler.TYPE_UPLOAD);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查成员类是否是静态和public
|
||||
*/
|
||||
|
||||
@@ -101,6 +101,9 @@ public class ComponentUtil {
|
||||
public <T extends IUtil> T buildUtil(AbsTaskWrapper wrapper, IEventListener listener) {
|
||||
int requestType = wrapper.getRequestType();
|
||||
String className = null;
|
||||
if (requestType == 1){
|
||||
throw new IllegalArgumentException("xxxx");
|
||||
}
|
||||
switch (requestType) {
|
||||
case ITaskWrapper.M3U8_LIVE:
|
||||
className = "com.arialyy.aria.m3u8.live.M3U8LiveUtil";
|
||||
|
||||
@@ -50,17 +50,7 @@ public class ErrorHelp {
|
||||
CommonUtil.getAppPath(AriaConfig.getInstance().getAPP()),
|
||||
getData("yyyy-MM-dd_HH_mm_ss"));
|
||||
|
||||
File log = new File(path);
|
||||
if (!log.getParentFile().exists()) {
|
||||
log.getParentFile().mkdirs();
|
||||
}
|
||||
if (!log.exists()) {
|
||||
try {
|
||||
log.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
FileUtil.createFile(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ public class RecordUtil {
|
||||
filePath = ((DownloadEntity) entity).getDownloadPath();
|
||||
} else if (entity instanceof UploadEntity) {
|
||||
type = IRecordHandler.TYPE_UPLOAD;
|
||||
filePath = ((UploadEntity) entity).getFilePath();
|
||||
filePath = entity.getFilePath();
|
||||
} else {
|
||||
ALog.w(TAG, "删除记录失败,未知类型");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user