3.7.10
This commit is contained in:
@@ -54,11 +54,6 @@ public class DTaskWrapper extends AbsTaskWrapper<DownloadEntity> {
|
||||
*/
|
||||
private String mTempFilePath;
|
||||
|
||||
/**
|
||||
* {@code true}强制下载,不考虑文件路径是否被占用
|
||||
*/
|
||||
private boolean forceDownload = false;
|
||||
|
||||
public DTaskWrapper(DownloadEntity entity) {
|
||||
super(entity);
|
||||
}
|
||||
@@ -124,12 +119,4 @@ public class DTaskWrapper extends AbsTaskWrapper<DownloadEntity> {
|
||||
public void setTempFilePath(String mTempFilePath) {
|
||||
this.mTempFilePath = mTempFilePath;
|
||||
}
|
||||
|
||||
public boolean isForceDownload() {
|
||||
return forceDownload;
|
||||
}
|
||||
|
||||
public void setForceDownload(boolean forceDownload) {
|
||||
this.forceDownload = forceDownload;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,6 @@ public class UTaskWrapper extends AbsTaskWrapper<UploadEntity> {
|
||||
*/
|
||||
private String tempUrl;
|
||||
|
||||
/**
|
||||
* 如果文件路径被其它任务占用,设置为true时,删除其它任务
|
||||
*/
|
||||
private boolean forceUpload = false;
|
||||
|
||||
public UTaskWrapper(UploadEntity entity) {
|
||||
super(entity);
|
||||
}
|
||||
@@ -53,14 +48,6 @@ public class UTaskWrapper extends AbsTaskWrapper<UploadEntity> {
|
||||
return getEntity().getKey();
|
||||
}
|
||||
|
||||
public boolean isForceUpload() {
|
||||
return forceUpload;
|
||||
}
|
||||
|
||||
public void setForceUpload(boolean forceUpload) {
|
||||
this.forceUpload = forceUpload;
|
||||
}
|
||||
|
||||
@Override public UploadConfig getConfig() {
|
||||
return Configuration.getInstance().uploadCfg;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.arialyy.aria.core.event.ErrorEvent;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.core.inf.ITaskOption;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.ComponentUtil;
|
||||
|
||||
/**
|
||||
@@ -85,6 +84,19 @@ public abstract class AbsTaskWrapper<ENTITY extends AbsEntity>
|
||||
*/
|
||||
private TaskOptionParams optionParams = new TaskOptionParams();
|
||||
|
||||
/**
|
||||
* {@code true}强制下载\上传,不考虑文件路径是否被占用
|
||||
*/
|
||||
private boolean ignoreFilePathOccupy = false;
|
||||
|
||||
public boolean isIgnoreFilePathOccupy() {
|
||||
return ignoreFilePathOccupy;
|
||||
}
|
||||
|
||||
public void setIgnoreFilePathOccupy(boolean ignoreFilePathOccupy) {
|
||||
this.ignoreFilePathOccupy = ignoreFilePathOccupy;
|
||||
}
|
||||
|
||||
public void setTaskOption(ITaskOption option) {
|
||||
this.taskOption = option;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.arialyy.aria.util;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.DownloadGroupEntity;
|
||||
import com.arialyy.aria.core.inf.IRecordHandler;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.orm.DbEntity;
|
||||
@@ -32,13 +33,13 @@ public class CheckUtil {
|
||||
private static final String TAG = "CheckUtil";
|
||||
|
||||
/**
|
||||
* 检查和处理路径冲突
|
||||
* 检查和处理下载任务的路径冲突
|
||||
*
|
||||
* @param isForceDownload true,如果路径冲突,将删除其它任务的记录的
|
||||
* @param filePath 文件保存路径
|
||||
* @return false 任务不再执行,true 任务继续执行
|
||||
*/
|
||||
public static boolean checkDownloadPathConflicts(boolean isForceDownload, String filePath) {
|
||||
public static boolean checkDPathConflicts(boolean isForceDownload, String filePath) {
|
||||
if (DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=?", filePath)) {
|
||||
if (!isForceDownload) {
|
||||
ALog.e(TAG, String.format("下载失败,保存路径【%s】已经被其它任务占用,请设置其它保存路径", filePath));
|
||||
@@ -53,13 +54,13 @@ public class CheckUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查和处理路径冲突
|
||||
* 检查和处理上传任务的路径冲突
|
||||
*
|
||||
* @param isForceUpload true,如果路径冲突,将删除其它任务的记录的
|
||||
* @param filePath 文件保存路径
|
||||
* @return false 任务不再执行,true 任务继续执行
|
||||
*/
|
||||
public static boolean checkUploadPathConflicts(boolean isForceUpload, String filePath) {
|
||||
public static boolean checkUPathConflicts(boolean isForceUpload, String filePath) {
|
||||
if (DbEntity.checkDataExist(UploadEntity.class, "filePath=?", filePath)) {
|
||||
if (!isForceUpload) {
|
||||
ALog.e(TAG, String.format("上传失败,文件路径【%s】已经被其它任务占用,请设置其它文件路径", filePath));
|
||||
@@ -73,6 +74,27 @@ public class CheckUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查和处理组合任务的路径冲突
|
||||
*
|
||||
* @param isForceDownload true,如果路径冲突,将删除其它任务的记录的
|
||||
* @param dirPath 文件保存路径
|
||||
* @return false 任务不再执行,true 任务继续执行
|
||||
*/
|
||||
public static boolean checkDGPathConflicts(boolean isForceDownload, String dirPath) {
|
||||
if (DbEntity.checkDataExist(DownloadGroupEntity.class, "dirPath=?", dirPath)) {
|
||||
if (!isForceDownload) {
|
||||
ALog.e(TAG, String.format("下载失败,文件夹路径【%s】已经被其它任务占用,请设置其它文件路径", dirPath));
|
||||
return false;
|
||||
} else {
|
||||
ALog.w(TAG, String.format("文件夹路径【%s】已经被其它任务占用,当前任务将覆盖该路径", dirPath));
|
||||
RecordUtil.delGroupTaskRecordByPath(dirPath, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查成员类是否是静态和public
|
||||
*/
|
||||
|
||||
@@ -52,7 +52,7 @@ public class DbDataHelper {
|
||||
* @param groupHash 组合任务Hash
|
||||
* @return 实体不存在,返回null
|
||||
*/
|
||||
public static DownloadGroupEntity getDGEntity(String groupHash) {
|
||||
public static DownloadGroupEntity getDGEntityByHash(String groupHash) {
|
||||
List<DGEntityWrapper> wrapper =
|
||||
DbEntity.findRelationData(DGEntityWrapper.class, "DownloadGroupEntity.groupHash=?",
|
||||
groupHash);
|
||||
@@ -60,6 +60,20 @@ public class DbDataHelper {
|
||||
return wrapper == null || wrapper.size() == 0 ? null : wrapper.get(0).groupEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组合任务实体、ftpDir任务实体
|
||||
*
|
||||
* @param dirPath 组合任务Hash
|
||||
* @return 实体不存在,返回null
|
||||
*/
|
||||
public static DownloadGroupEntity getDGEntityByPath(String dirPath) {
|
||||
List<DGEntityWrapper> wrapper =
|
||||
DbEntity.findRelationData(DGEntityWrapper.class, "DownloadGroupEntity.dirPath=?",
|
||||
dirPath);
|
||||
|
||||
return wrapper == null || wrapper.size() == 0 ? null : wrapper.get(0).groupEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组合任务实体、ftpDir任务实体
|
||||
*
|
||||
|
||||
@@ -42,12 +42,28 @@ public class RecordUtil {
|
||||
* @param removeFile {@code true} 无论任务是否完成,都会删除记录和文件;
|
||||
* {@code false} 如果任务已经完成,则只删除记录,不删除文件;任务未完成,记录和文件都会删除。
|
||||
*/
|
||||
public static void delGroupTaskRecord(String groupHash, boolean removeFile) {
|
||||
public static void delGroupTaskRecordByHash(String groupHash, boolean removeFile) {
|
||||
if (TextUtils.isEmpty(groupHash)) {
|
||||
ALog.e(TAG, "删除下载任务组记录失败,groupHash为null");
|
||||
return;
|
||||
}
|
||||
DownloadGroupEntity groupEntity = DbDataHelper.getDGEntity(groupHash);
|
||||
DownloadGroupEntity groupEntity = DbDataHelper.getDGEntityByHash(groupHash);
|
||||
|
||||
delGroupTaskRecord(groupEntity, removeFile, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据路径删除组合任务记录
|
||||
*
|
||||
* @param removeFile {@code true} 无论任务是否完成,都会删除记录和文件;
|
||||
* {@code false} 如果任务已经完成,则只删除记录,不删除文件;任务未完成,记录和文件都会删除。
|
||||
*/
|
||||
public static void delGroupTaskRecordByPath(String dirPath, boolean removeFile) {
|
||||
if (TextUtils.isEmpty(dirPath)) {
|
||||
ALog.e(TAG, "删除下载任务组记录失败,组合任务路径为空");
|
||||
return;
|
||||
}
|
||||
DownloadGroupEntity groupEntity = DbDataHelper.getDGEntityByPath(dirPath);
|
||||
|
||||
delGroupTaskRecord(groupEntity, removeFile, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user