3.7.10
This commit is contained in:
@@ -282,7 +282,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
RecordUtil.delTaskRecord(key, IRecordHandler.TYPE_DOWNLOAD, removeFile, true);
|
||||
break;
|
||||
case 2:
|
||||
RecordUtil.delGroupTaskRecord(key, removeFile);
|
||||
RecordUtil.delGroupTaskRecordByHash(key, removeFile);
|
||||
break;
|
||||
case 3:
|
||||
RecordUtil.delTaskRecord(key, IRecordHandler.TYPE_UPLOAD);
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.arialyy.aria.core.common.controller.IStartFeature;
|
||||
import com.arialyy.aria.core.inf.AbsTarget;
|
||||
|
||||
/**
|
||||
* 处理第一次下载
|
||||
* 处理第一次创建的任务
|
||||
*/
|
||||
public abstract class AbsBuilderTarget<TARGET extends AbsBuilderTarget> extends AbsTarget<TARGET>
|
||||
implements IStartFeature {
|
||||
@@ -42,6 +42,15 @@ public abstract class AbsBuilderTarget<TARGET extends AbsBuilderTarget> extends
|
||||
return (TARGET) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 忽略文件占用,不管文件路径是否被其它任务占用,都执行上传\下载任务
|
||||
* 需要注意的是:如果文件被其它任务占用,并且还调用了该方法,将自动删除占用了该文件路径的任务
|
||||
*/
|
||||
public TARGET ignoreFilePathOccupy() {
|
||||
getController().ignoreFilePathOccupy();
|
||||
return (TARGET) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加任务
|
||||
*
|
||||
|
||||
@@ -98,6 +98,13 @@ public abstract class FeatureController {
|
||||
this.ignoreCheckPermissions = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制执行任务,不管文件路径是否被占用
|
||||
*/
|
||||
public void ignoreFilePathOccupy() {
|
||||
mTaskWrapper.setIgnoreFilePathOccupy(true);
|
||||
}
|
||||
|
||||
protected AbsTaskWrapper getTaskWrapper() {
|
||||
return mTaskWrapper;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class CheckDEntityUtil implements ICheckEntityUtil {
|
||||
//设置文件保存路径,如果新文件路径和旧文件路径不同,则修改路径
|
||||
if (!filePath.equals(mEntity.getFilePath())) {
|
||||
// 检查路径冲突
|
||||
if (!CheckUtil.checkDownloadPathConflicts(mWrapper.isForceDownload(), filePath)) {
|
||||
if (!CheckUtil.checkDPathConflicts(mWrapper.isIgnoreFilePathOccupy(), filePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
package com.arialyy.aria.core.download;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.common.ErrorCode;
|
||||
import com.arialyy.aria.core.common.RequestEnum;
|
||||
import com.arialyy.aria.core.inf.ICheckEntityUtil;
|
||||
import com.arialyy.aria.core.inf.IOptionConstant;
|
||||
import com.arialyy.aria.orm.DbEntity;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CheckUtil;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.aria.util.RecordUtil;
|
||||
import java.io.File;
|
||||
@@ -70,10 +70,9 @@ public class CheckDGEntityUtil implements ICheckEntityUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((mEntity.getDirPath() == null || !mEntity.getDirPath().equals(mWrapper.getDirPathTemp()))
|
||||
&& DbEntity.checkDataExist(DownloadGroupEntity.class, "dirPath=?",
|
||||
// 检查路径冲突
|
||||
if (mWrapper.isNewTask() && !CheckUtil.checkDGPathConflicts(mWrapper.isIgnoreFilePathOccupy(),
|
||||
mWrapper.getDirPathTemp())) {
|
||||
ALog.e(TAG, String.format("文件夹路径【%s】已被其它任务占用,请重新设置文件夹路径", mWrapper.getDirPathTemp()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ public class DownloadReceiver extends AbsReceiver {
|
||||
if (CheckUtil.checkDownloadUrlsIsEmpty(urls)) {
|
||||
return null;
|
||||
}
|
||||
return DbDataHelper.getDGEntity(CommonUtil.getMd5Code(urls));
|
||||
return DbDataHelper.getDGEntityByHash(CommonUtil.getMd5Code(urls));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,7 +304,7 @@ public class DownloadReceiver extends AbsReceiver {
|
||||
if (!CheckUtil.checkUrl(url)) {
|
||||
return null;
|
||||
}
|
||||
return DbDataHelper.getDGEntity(url);
|
||||
return DbDataHelper.getDGEntityByHash(url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,7 +93,7 @@ class DNormalConfigHandler<TARGET extends AbsTarget> implements IConfigHandler {
|
||||
}
|
||||
|
||||
void setForceDownload(boolean forceDownload) {
|
||||
getWrapper().setForceDownload(forceDownload);
|
||||
getWrapper().setIgnoreFilePathOccupy(forceDownload);
|
||||
}
|
||||
|
||||
void setUrl(String url) {
|
||||
|
||||
@@ -34,6 +34,7 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
|
||||
mConfigHandler = new DNormalConfigHandler<>(this, -1);
|
||||
mConfigHandler.setUrl(url);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.D_FTP);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +71,9 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
|
||||
*
|
||||
* @param filePath 路径必须为文件路径,不能为文件夹路径
|
||||
* @param forceDownload {@code true}强制下载,不考虑文件路径是否被占用
|
||||
* @deprecated 使用 {@link #ignoreFilePathOccupy()}
|
||||
*/
|
||||
@Deprecated
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
public FtpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) {
|
||||
mConfigHandler.setTempFilePath(filePath);
|
||||
|
||||
@@ -35,6 +35,7 @@ public class FtpDirBuilderTarget extends AbsBuilderTarget<FtpDirBuilderTarget> {
|
||||
this.url = url;
|
||||
mConfigHandler = new FtpDirConfigHandler<>(this, -1);
|
||||
getEntity().setGroupHash(url);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,6 +32,7 @@ public class FtpDirNormalTarget extends AbsNormalTarget<FtpDirNormalTarget> {
|
||||
|
||||
FtpDirNormalTarget(long taskId) {
|
||||
mConfigHandler = new FtpDirConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
@Override public boolean isRunning() {
|
||||
|
||||
@@ -34,6 +34,7 @@ public class FtpNormalTarget extends AbsNormalTarget<FtpNormalTarget> {
|
||||
FtpNormalTarget(long taskId) {
|
||||
mConfigHandler = new DNormalConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.D_FTP);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,8 +34,9 @@ public class GroupBuilderTarget extends AbsBuilderTarget<GroupBuilderTarget> {
|
||||
|
||||
GroupBuilderTarget(List<String> urls) {
|
||||
mConfigHandler = new HttpGroupConfigHandler<>(this, -1);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.DG_HTTP);
|
||||
mConfigHandler.setGroupUrl(urls);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.DG_HTTP);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,7 @@ public class GroupNormalTarget extends AbsNormalTarget<GroupNormalTarget> {
|
||||
GroupNormalTarget(long taskId) {
|
||||
mConfigHandler = new HttpGroupConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.DG_HTTP);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,12 +22,9 @@ import com.arialyy.aria.core.common.HttpOption;
|
||||
import com.arialyy.aria.core.download.DTaskWrapper;
|
||||
import com.arialyy.aria.core.download.m3u8.M3U8LiveOption;
|
||||
import com.arialyy.aria.core.download.m3u8.M3U8VodOption;
|
||||
import com.arialyy.aria.core.inf.IOptionConstant;
|
||||
import com.arialyy.aria.core.inf.Suggest;
|
||||
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||
import com.arialyy.aria.util.CheckUtil;
|
||||
|
||||
public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
|
||||
@@ -35,13 +32,14 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
|
||||
HttpBuilderTarget(String url) {
|
||||
mConfigHandler = new DNormalConfigHandler<>(this, -1);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.D_HTTP);
|
||||
mConfigHandler.setUrl(url);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.D_HTTP);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
public HttpBuilderTarget m3u8VodOption(M3U8VodOption m3U8VodOption) {
|
||||
if (m3U8VodOption == null){
|
||||
if (m3U8VodOption == null) {
|
||||
throw new NullPointerException("m3u8任务设置为空");
|
||||
}
|
||||
getTaskWrapper().setRequestType(AbsTaskWrapper.M3U8_VOD);
|
||||
@@ -52,7 +50,7 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
public HttpBuilderTarget m3u8LiveOption(M3U8LiveOption m3U8LiveOption) {
|
||||
if (m3U8LiveOption == null){
|
||||
if (m3U8LiveOption == null) {
|
||||
throw new NullPointerException("m3u8任务设置为空");
|
||||
}
|
||||
getTaskWrapper().setRequestType(AbsTaskWrapper.M3U8_LIVE);
|
||||
@@ -92,7 +90,9 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
*
|
||||
* @param filePath 路径必须为文件路径,不能为文件夹路径
|
||||
* @param forceDownload {@code true}强制下载,不考虑文件路径是否被占用
|
||||
* @deprecated 使用 {@link #ignoreFilePathOccupy()}
|
||||
*/
|
||||
@Deprecated
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
public HttpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) {
|
||||
mConfigHandler.setTempFilePath(filePath);
|
||||
|
||||
@@ -35,6 +35,7 @@ public class HttpNormalTarget extends AbsNormalTarget<HttpNormalTarget> {
|
||||
HttpNormalTarget(long taskId) {
|
||||
mConfigHandler = new DNormalConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setRequestType(getTaskWrapper().getEntity().getTaskType());
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
|
||||
@@ -27,6 +27,7 @@ public class M3U8NormalTarget extends AbsNormalTarget<M3U8NormalTarget> {
|
||||
|
||||
M3U8NormalTarget(DTaskWrapper wrapper) {
|
||||
setTaskWrapper(wrapper);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,7 @@ public class TcpBuilderTarget extends AbsBuilderTarget<TcpBuilderTarget> {
|
||||
TcpBuilderTarget(String ip, int port) {
|
||||
mConfigHandler = new DNormalConfigHandler<>(this, -1);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.D_TCP);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
//
|
||||
///**
|
||||
@@ -56,18 +57,4 @@ public class TcpBuilderTarget extends AbsBuilderTarget<TcpBuilderTarget> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置文件存储路径,如果需要修改新的文件名,修改路径便可。
|
||||
* 如:原文件路径 /mnt/sdcard/test.zip
|
||||
* 如果需要将test.zip改为game.zip,只需要重新设置文件路径为:/mnt/sdcard/game.zip
|
||||
*
|
||||
* @param filePath 路径必须为文件路径,不能为文件夹路径
|
||||
* @param forceDownload {@code true}强制下载,不考虑文件路径是否被占用
|
||||
*/
|
||||
@CheckResult(suggest = Suggest.TASK_CONTROLLER)
|
||||
public TcpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) {
|
||||
mConfigHandler.setTempFilePath(filePath);
|
||||
mConfigHandler.setForceDownload(forceDownload);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ public class CheckUEntityUtil implements ICheckEntityUtil {
|
||||
ALog.e(TAG, "上传失败,文件路径【" + filePath + "】不合法");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查路径冲突
|
||||
if (!CheckUtil.checkUploadPathConflicts(mWrapper.isForceUpload(), filePath)) {
|
||||
// 任务是新任务,并且路径冲突就不会继续执行
|
||||
if (mWrapper.isNewTask() && !CheckUtil.checkUPathConflicts(
|
||||
mWrapper.isIgnoreFilePathOccupy(), filePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +52,12 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
|
||||
|
||||
/**
|
||||
* 如果文件路径被其它任务占用,删除其它任务
|
||||
*
|
||||
* @deprecated 使用 {@link #ignoreFilePathOccupy()}
|
||||
*/
|
||||
@Deprecated
|
||||
public FtpBuilderTarget forceUpload() {
|
||||
((UTaskWrapper)getTaskWrapper()).setForceUpload(true);
|
||||
getTaskWrapper().setIgnoreFilePathOccupy(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public class FtpNormalTarget extends AbsNormalTarget<FtpNormalTarget> {
|
||||
FtpNormalTarget(long taskId) {
|
||||
mConfigHandler = new UNormalConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setRequestType(ITaskWrapper.U_FTP);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,6 @@ import androidx.annotation.CheckResult;
|
||||
import com.arialyy.aria.core.common.AbsBuilderTarget;
|
||||
import com.arialyy.aria.core.common.HttpOption;
|
||||
import com.arialyy.aria.core.inf.Suggest;
|
||||
import com.arialyy.aria.core.upload.UTaskWrapper;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
|
||||
/**
|
||||
@@ -30,12 +29,12 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
private UNormalConfigHandler<HttpBuilderTarget> mConfigHandler;
|
||||
|
||||
HttpBuilderTarget(String filePath) {
|
||||
|
||||
mConfigHandler = new UNormalConfigHandler<>(this, -1);
|
||||
mConfigHandler.setFilePath(filePath);
|
||||
//http暂时不支持断点上传
|
||||
getTaskWrapper().setSupportBP(false);
|
||||
getTaskWrapper().setRequestType(AbsTaskWrapper.U_HTTP);
|
||||
getTaskWrapper().setNewTask(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,9 +63,12 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
|
||||
|
||||
/**
|
||||
* 如果文件路径被其它任务占用,删除其它任务
|
||||
*
|
||||
* @deprecated 使用 {@link #ignoreFilePathOccupy()}
|
||||
*/
|
||||
@Deprecated
|
||||
public HttpBuilderTarget forceUpload() {
|
||||
((UTaskWrapper) getTaskWrapper()).setForceUpload(true);
|
||||
getTaskWrapper().setIgnoreFilePathOccupy(true);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public class HttpNormalTarget extends AbsNormalTarget<HttpNormalTarget> {
|
||||
mConfigHandler = new UNormalConfigHandler<>(this, taskId);
|
||||
getTaskWrapper().setSupportBP(false);
|
||||
getTaskWrapper().setRequestType(AbsTaskWrapper.U_HTTP);
|
||||
getTaskWrapper().setNewTask(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user