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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
## 开发日志
|
||||
+ v_3.7.10
|
||||
+ v_3.7.10 (2019/12/3)
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/543#issuecomment-559733124
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/542
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/547
|
||||
- 修复下载失败时,中断重试无效的问题
|
||||
- 增加忽略权限检查的api,`ignoreCheckPermissions()`
|
||||
- 增加通用的的忽略文件路径被占用的api,`isIgnoreFilePathOccupy()`
|
||||
+ v_3.7.9 (2019/11/28)
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/537
|
||||
+ v_3.7.8 (2019/11/28)
|
||||
|
||||
@@ -74,7 +74,7 @@ public class FtpDirInfoThread extends AbsFtpInfoThread<DownloadGroupEntity, DGTa
|
||||
entity.setConvertFileSize(CommonUtil.formatFileSize(ftpFile.getSize()));
|
||||
entity.setFileSize(ftpFile.getSize());
|
||||
|
||||
//if(CheckUtil.checkDownloadPathConflicts(mTaskWrapper.is))
|
||||
//if(CheckUtil.checkDPathConflicts(mTaskWrapper.is))
|
||||
|
||||
entity.insert();
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
25
README.md
25
README.md
@@ -44,16 +44,16 @@ Aria有以下特点:
|
||||
|
||||
## 引入库
|
||||
[](https://github.com/AriaLyy/Aria/blob/master/LICENSE)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
[](https://github.com/AriaLyy/Aria)
|
||||
|
||||
```java
|
||||
implementation 'com.arialyy.aria:core:3.7.9'
|
||||
annotationProcessor 'com.arialyy.aria:compiler:3.7.9'
|
||||
implementation 'com.arialyy.aria:ftpComponent:3.7.9' # 如果需要使用ftp,请增加该组件
|
||||
implementation 'com.arialyy.aria:m3u8Component:3.7.9' # 如果需要使用m3u8下载功能,请增加该组件
|
||||
implementation 'com.arialyy.aria:core:3.7.10'
|
||||
annotationProcessor 'com.arialyy.aria:compiler:3.7.10'
|
||||
implementation 'com.arialyy.aria:ftpComponent:3.7.10' # 如果需要使用ftp,请增加该组件
|
||||
implementation 'com.arialyy.aria:m3u8Component:3.7.10' # 如果需要使用m3u8下载功能,请增加该组件
|
||||
```
|
||||
如果出现android support依赖错误,请将 `compile 'com.arialyy.aria:core:<last-version>'`替换为
|
||||
```
|
||||
@@ -137,8 +137,13 @@ protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
|
||||
### 版本日志
|
||||
+ v_3.7.9 (2019/11/28)
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/537
|
||||
+ v_3.7.10 (2019/12/3)
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/543#issuecomment-559733124
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/542
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/547
|
||||
- 修复下载失败时,中断重试无效的问题
|
||||
- 增加忽略权限检查的api,`ignoreCheckPermissions()`
|
||||
- 增加通用的的忽略文件路径被占用的api,`isIgnoreFilePathOccupy()`
|
||||
|
||||
[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)
|
||||
|
||||
|
||||
@@ -96,11 +96,11 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
||||
.loadGroup(mUrls)
|
||||
.setDirPath(
|
||||
Environment.getExternalStorageDirectory().getPath() + "/Download/group_imgs")
|
||||
.setGroupAlias("图片测试")
|
||||
//.setSubFileName(getModule(GroupModule.class).getSubName2())
|
||||
//.setSubFileName(getModule(GroupModule.class).getSubName())
|
||||
.unknownSize()
|
||||
.option(getHttpOption())
|
||||
.ignoreFilePathOccupy()
|
||||
//.setFileSize(114981416)
|
||||
//.updateUrls(temp)
|
||||
.create();
|
||||
|
||||
@@ -45,7 +45,7 @@ task clean(type: Delete) {
|
||||
|
||||
ext {
|
||||
versionCode = 380
|
||||
versionName = '3.7.10_pre_3'
|
||||
versionName = '3.7.10'
|
||||
userOrg = 'arialyy'
|
||||
groupId = 'com.arialyy.aria'
|
||||
publishVersion = versionName
|
||||
|
||||
Reference in New Issue
Block a user