pull/617/head 3.7.10
laoyuyu 5 years ago
parent 669aa6981c
commit 3871d8f056
  1. 2
      Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
  2. 11
      Aria/src/main/java/com/arialyy/aria/core/common/AbsBuilderTarget.java
  3. 7
      Aria/src/main/java/com/arialyy/aria/core/common/controller/FeatureController.java
  4. 2
      Aria/src/main/java/com/arialyy/aria/core/download/CheckDEntityUtil.java
  5. 7
      Aria/src/main/java/com/arialyy/aria/core/download/CheckDGEntityUtil.java
  6. 4
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java
  7. 2
      Aria/src/main/java/com/arialyy/aria/core/download/target/DNormalConfigHandler.java
  8. 3
      Aria/src/main/java/com/arialyy/aria/core/download/target/FtpBuilderTarget.java
  9. 1
      Aria/src/main/java/com/arialyy/aria/core/download/target/FtpDirBuilderTarget.java
  10. 1
      Aria/src/main/java/com/arialyy/aria/core/download/target/FtpDirNormalTarget.java
  11. 1
      Aria/src/main/java/com/arialyy/aria/core/download/target/FtpNormalTarget.java
  12. 3
      Aria/src/main/java/com/arialyy/aria/core/download/target/GroupBuilderTarget.java
  13. 1
      Aria/src/main/java/com/arialyy/aria/core/download/target/GroupNormalTarget.java
  14. 12
      Aria/src/main/java/com/arialyy/aria/core/download/target/HttpBuilderTarget.java
  15. 1
      Aria/src/main/java/com/arialyy/aria/core/download/target/HttpNormalTarget.java
  16. 1
      Aria/src/main/java/com/arialyy/aria/core/download/target/M3U8NormalTarget.java
  17. 15
      Aria/src/main/java/com/arialyy/aria/core/download/target/TcpBuilderTarget.java
  18. 6
      Aria/src/main/java/com/arialyy/aria/core/upload/CheckUEntityUtil.java
  19. 5
      Aria/src/main/java/com/arialyy/aria/core/upload/target/FtpBuilderTarget.java
  20. 1
      Aria/src/main/java/com/arialyy/aria/core/upload/target/FtpNormalTarget.java
  21. 8
      Aria/src/main/java/com/arialyy/aria/core/upload/target/HttpBuilderTarget.java
  22. 1
      Aria/src/main/java/com/arialyy/aria/core/upload/target/HttpNormalTarget.java
  23. 3
      DEV_LOG.md
  24. 2
      FtpComponent/src/main/java/com/arialyy/aria/ftp/FtpDirInfoThread.java
  25. 13
      PublicComponent/src/main/java/com/arialyy/aria/core/download/DTaskWrapper.java
  26. 13
      PublicComponent/src/main/java/com/arialyy/aria/core/upload/UTaskWrapper.java
  27. 14
      PublicComponent/src/main/java/com/arialyy/aria/core/wrapper/AbsTaskWrapper.java
  28. 30
      PublicComponent/src/main/java/com/arialyy/aria/util/CheckUtil.java
  29. 16
      PublicComponent/src/main/java/com/arialyy/aria/util/DbDataHelper.java
  30. 20
      PublicComponent/src/main/java/com/arialyy/aria/util/RecordUtil.java
  31. 25
      README.md
  32. 2
      app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java
  33. 2
      build.gradle

@ -282,7 +282,7 @@ import java.util.concurrent.ConcurrentHashMap;
RecordUtil.delTaskRecord(key, IRecordHandler.TYPE_DOWNLOAD, removeFile, true); RecordUtil.delTaskRecord(key, IRecordHandler.TYPE_DOWNLOAD, removeFile, true);
break; break;
case 2: case 2:
RecordUtil.delGroupTaskRecord(key, removeFile); RecordUtil.delGroupTaskRecordByHash(key, removeFile);
break; break;
case 3: case 3:
RecordUtil.delTaskRecord(key, IRecordHandler.TYPE_UPLOAD); 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; import com.arialyy.aria.core.inf.AbsTarget;
/** /**
* 处理第一次下载 * 处理第一次创建的任务
*/ */
public abstract class AbsBuilderTarget<TARGET extends AbsBuilderTarget> extends AbsTarget<TARGET> public abstract class AbsBuilderTarget<TARGET extends AbsBuilderTarget> extends AbsTarget<TARGET>
implements IStartFeature { implements IStartFeature {
@ -42,6 +42,15 @@ public abstract class AbsBuilderTarget<TARGET extends AbsBuilderTarget> extends
return (TARGET) this; return (TARGET) this;
} }
/**
* 忽略文件占用不管文件路径是否被其它任务占用都执行上传\下载任务
* 需要注意的是如果文件被其它任务占用并且还调用了该方法将自动删除占用了该文件路径的任务
*/
public TARGET ignoreFilePathOccupy() {
getController().ignoreFilePathOccupy();
return (TARGET) this;
}
/** /**
* 添加任务 * 添加任务
* *

@ -98,6 +98,13 @@ public abstract class FeatureController {
this.ignoreCheckPermissions = true; this.ignoreCheckPermissions = true;
} }
/**
* 强制执行任务不管文件路径是否被占用
*/
public void ignoreFilePathOccupy() {
mTaskWrapper.setIgnoreFilePathOccupy(true);
}
protected AbsTaskWrapper getTaskWrapper() { protected AbsTaskWrapper getTaskWrapper() {
return mTaskWrapper; return mTaskWrapper;
} }

@ -134,7 +134,7 @@ public class CheckDEntityUtil implements ICheckEntityUtil {
//设置文件保存路径,如果新文件路径和旧文件路径不同,则修改路径 //设置文件保存路径,如果新文件路径和旧文件路径不同,则修改路径
if (!filePath.equals(mEntity.getFilePath())) { if (!filePath.equals(mEntity.getFilePath())) {
// 检查路径冲突 // 检查路径冲突
if (!CheckUtil.checkDownloadPathConflicts(mWrapper.isForceDownload(), filePath)) { if (!CheckUtil.checkDPathConflicts(mWrapper.isIgnoreFilePathOccupy(), filePath)) {
return false; return false;
} }

@ -16,12 +16,12 @@
package com.arialyy.aria.core.download; package com.arialyy.aria.core.download;
import android.text.TextUtils; import android.text.TextUtils;
import com.arialyy.aria.core.common.ErrorCode;
import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.common.RequestEnum;
import com.arialyy.aria.core.inf.ICheckEntityUtil; import com.arialyy.aria.core.inf.ICheckEntityUtil;
import com.arialyy.aria.core.inf.IOptionConstant; import com.arialyy.aria.core.inf.IOptionConstant;
import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.RecordUtil; import com.arialyy.aria.util.RecordUtil;
import java.io.File; import java.io.File;
@ -70,10 +70,9 @@ public class CheckDGEntityUtil implements ICheckEntityUtil {
return false; 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())) { mWrapper.getDirPathTemp())) {
ALog.e(TAG, String.format("文件夹路径【%s】已被其它任务占用,请重新设置文件夹路径", mWrapper.getDirPathTemp()));
return false; return false;
} }

@ -291,7 +291,7 @@ public class DownloadReceiver extends AbsReceiver {
if (CheckUtil.checkDownloadUrlsIsEmpty(urls)) { if (CheckUtil.checkDownloadUrlsIsEmpty(urls)) {
return null; 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)) { if (!CheckUtil.checkUrl(url)) {
return null; 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) { void setForceDownload(boolean forceDownload) {
getWrapper().setForceDownload(forceDownload); getWrapper().setIgnoreFilePathOccupy(forceDownload);
} }
void setUrl(String url) { void setUrl(String url) {

@ -34,6 +34,7 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
mConfigHandler = new DNormalConfigHandler<>(this, -1); mConfigHandler = new DNormalConfigHandler<>(this, -1);
mConfigHandler.setUrl(url); mConfigHandler.setUrl(url);
getTaskWrapper().setRequestType(ITaskWrapper.D_FTP); getTaskWrapper().setRequestType(ITaskWrapper.D_FTP);
getTaskWrapper().setNewTask(true);
} }
/** /**
@ -70,7 +71,9 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
* *
* @param filePath 路径必须为文件路径不能为文件夹路径 * @param filePath 路径必须为文件路径不能为文件夹路径
* @param forceDownload {@code true}强制下载不考虑文件路径是否被占用 * @param forceDownload {@code true}强制下载不考虑文件路径是否被占用
* @deprecated 使用 {@link #ignoreFilePathOccupy()}
*/ */
@Deprecated
@CheckResult(suggest = Suggest.TASK_CONTROLLER) @CheckResult(suggest = Suggest.TASK_CONTROLLER)
public FtpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) { public FtpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) {
mConfigHandler.setTempFilePath(filePath); mConfigHandler.setTempFilePath(filePath);

@ -35,6 +35,7 @@ public class FtpDirBuilderTarget extends AbsBuilderTarget<FtpDirBuilderTarget> {
this.url = url; this.url = url;
mConfigHandler = new FtpDirConfigHandler<>(this, -1); mConfigHandler = new FtpDirConfigHandler<>(this, -1);
getEntity().setGroupHash(url); getEntity().setGroupHash(url);
getTaskWrapper().setNewTask(true);
} }
/** /**

@ -32,6 +32,7 @@ public class FtpDirNormalTarget extends AbsNormalTarget<FtpDirNormalTarget> {
FtpDirNormalTarget(long taskId) { FtpDirNormalTarget(long taskId) {
mConfigHandler = new FtpDirConfigHandler<>(this, taskId); mConfigHandler = new FtpDirConfigHandler<>(this, taskId);
getTaskWrapper().setNewTask(false);
} }
@Override public boolean isRunning() { @Override public boolean isRunning() {

@ -34,6 +34,7 @@ public class FtpNormalTarget extends AbsNormalTarget<FtpNormalTarget> {
FtpNormalTarget(long taskId) { FtpNormalTarget(long taskId) {
mConfigHandler = new DNormalConfigHandler<>(this, taskId); mConfigHandler = new DNormalConfigHandler<>(this, taskId);
getTaskWrapper().setRequestType(ITaskWrapper.D_FTP); getTaskWrapper().setRequestType(ITaskWrapper.D_FTP);
getTaskWrapper().setNewTask(false);
} }
/** /**

@ -34,8 +34,9 @@ public class GroupBuilderTarget extends AbsBuilderTarget<GroupBuilderTarget> {
GroupBuilderTarget(List<String> urls) { GroupBuilderTarget(List<String> urls) {
mConfigHandler = new HttpGroupConfigHandler<>(this, -1); mConfigHandler = new HttpGroupConfigHandler<>(this, -1);
getTaskWrapper().setRequestType(ITaskWrapper.DG_HTTP);
mConfigHandler.setGroupUrl(urls); mConfigHandler.setGroupUrl(urls);
getTaskWrapper().setRequestType(ITaskWrapper.DG_HTTP);
getTaskWrapper().setNewTask(true);
} }
/** /**

@ -33,6 +33,7 @@ public class GroupNormalTarget extends AbsNormalTarget<GroupNormalTarget> {
GroupNormalTarget(long taskId) { GroupNormalTarget(long taskId) {
mConfigHandler = new HttpGroupConfigHandler<>(this, taskId); mConfigHandler = new HttpGroupConfigHandler<>(this, taskId);
getTaskWrapper().setRequestType(ITaskWrapper.DG_HTTP); 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.DTaskWrapper;
import com.arialyy.aria.core.download.m3u8.M3U8LiveOption; import com.arialyy.aria.core.download.m3u8.M3U8LiveOption;
import com.arialyy.aria.core.download.m3u8.M3U8VodOption; 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.inf.Suggest;
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.core.wrapper.ITaskWrapper; import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.util.CheckUtil;
public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> { public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
@ -35,13 +32,14 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
HttpBuilderTarget(String url) { HttpBuilderTarget(String url) {
mConfigHandler = new DNormalConfigHandler<>(this, -1); mConfigHandler = new DNormalConfigHandler<>(this, -1);
getTaskWrapper().setRequestType(ITaskWrapper.D_HTTP);
mConfigHandler.setUrl(url); mConfigHandler.setUrl(url);
getTaskWrapper().setRequestType(ITaskWrapper.D_HTTP);
getTaskWrapper().setNewTask(true);
} }
@CheckResult(suggest = Suggest.TASK_CONTROLLER) @CheckResult(suggest = Suggest.TASK_CONTROLLER)
public HttpBuilderTarget m3u8VodOption(M3U8VodOption m3U8VodOption) { public HttpBuilderTarget m3u8VodOption(M3U8VodOption m3U8VodOption) {
if (m3U8VodOption == null){ if (m3U8VodOption == null) {
throw new NullPointerException("m3u8任务设置为空"); throw new NullPointerException("m3u8任务设置为空");
} }
getTaskWrapper().setRequestType(AbsTaskWrapper.M3U8_VOD); getTaskWrapper().setRequestType(AbsTaskWrapper.M3U8_VOD);
@ -52,7 +50,7 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
@CheckResult(suggest = Suggest.TASK_CONTROLLER) @CheckResult(suggest = Suggest.TASK_CONTROLLER)
public HttpBuilderTarget m3u8LiveOption(M3U8LiveOption m3U8LiveOption) { public HttpBuilderTarget m3u8LiveOption(M3U8LiveOption m3U8LiveOption) {
if (m3U8LiveOption == null){ if (m3U8LiveOption == null) {
throw new NullPointerException("m3u8任务设置为空"); throw new NullPointerException("m3u8任务设置为空");
} }
getTaskWrapper().setRequestType(AbsTaskWrapper.M3U8_LIVE); getTaskWrapper().setRequestType(AbsTaskWrapper.M3U8_LIVE);
@ -92,7 +90,9 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
* *
* @param filePath 路径必须为文件路径不能为文件夹路径 * @param filePath 路径必须为文件路径不能为文件夹路径
* @param forceDownload {@code true}强制下载不考虑文件路径是否被占用 * @param forceDownload {@code true}强制下载不考虑文件路径是否被占用
* @deprecated 使用 {@link #ignoreFilePathOccupy()}
*/ */
@Deprecated
@CheckResult(suggest = Suggest.TASK_CONTROLLER) @CheckResult(suggest = Suggest.TASK_CONTROLLER)
public HttpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) { public HttpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) {
mConfigHandler.setTempFilePath(filePath); mConfigHandler.setTempFilePath(filePath);

@ -35,6 +35,7 @@ public class HttpNormalTarget extends AbsNormalTarget<HttpNormalTarget> {
HttpNormalTarget(long taskId) { HttpNormalTarget(long taskId) {
mConfigHandler = new DNormalConfigHandler<>(this, taskId); mConfigHandler = new DNormalConfigHandler<>(this, taskId);
getTaskWrapper().setRequestType(getTaskWrapper().getEntity().getTaskType()); getTaskWrapper().setRequestType(getTaskWrapper().getEntity().getTaskType());
getTaskWrapper().setNewTask(false);
} }
@CheckResult(suggest = Suggest.TASK_CONTROLLER) @CheckResult(suggest = Suggest.TASK_CONTROLLER)

@ -27,6 +27,7 @@ public class M3U8NormalTarget extends AbsNormalTarget<M3U8NormalTarget> {
M3U8NormalTarget(DTaskWrapper wrapper) { M3U8NormalTarget(DTaskWrapper wrapper) {
setTaskWrapper(wrapper); setTaskWrapper(wrapper);
getTaskWrapper().setNewTask(false);
} }
/** /**

@ -33,6 +33,7 @@ public class TcpBuilderTarget extends AbsBuilderTarget<TcpBuilderTarget> {
TcpBuilderTarget(String ip, int port) { TcpBuilderTarget(String ip, int port) {
mConfigHandler = new DNormalConfigHandler<>(this, -1); mConfigHandler = new DNormalConfigHandler<>(this, -1);
getTaskWrapper().setRequestType(ITaskWrapper.D_TCP); getTaskWrapper().setRequestType(ITaskWrapper.D_TCP);
getTaskWrapper().setNewTask(true);
} }
// //
///** ///**
@ -56,18 +57,4 @@ public class TcpBuilderTarget extends AbsBuilderTarget<TcpBuilderTarget> {
return this; 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 + "】不合法"); ALog.e(TAG, "上传失败,文件路径【" + filePath + "】不合法");
return false; return false;
} }
// 任务是新任务,并且路径冲突就不会继续执行
// 检查路径冲突 if (mWrapper.isNewTask() && !CheckUtil.checkUPathConflicts(
if (!CheckUtil.checkUploadPathConflicts(mWrapper.isForceUpload(), filePath)) { mWrapper.isIgnoreFilePathOccupy(), filePath)) {
return false; return false;
} }

@ -52,9 +52,12 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
/** /**
* 如果文件路径被其它任务占用删除其它任务 * 如果文件路径被其它任务占用删除其它任务
*
* @deprecated 使用 {@link #ignoreFilePathOccupy()}
*/ */
@Deprecated
public FtpBuilderTarget forceUpload() { public FtpBuilderTarget forceUpload() {
((UTaskWrapper)getTaskWrapper()).setForceUpload(true); getTaskWrapper().setIgnoreFilePathOccupy(true);
return this; return this;
} }

@ -33,6 +33,7 @@ public class FtpNormalTarget extends AbsNormalTarget<FtpNormalTarget> {
FtpNormalTarget(long taskId) { FtpNormalTarget(long taskId) {
mConfigHandler = new UNormalConfigHandler<>(this, taskId); mConfigHandler = new UNormalConfigHandler<>(this, taskId);
getTaskWrapper().setRequestType(ITaskWrapper.U_FTP); 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.AbsBuilderTarget;
import com.arialyy.aria.core.common.HttpOption; import com.arialyy.aria.core.common.HttpOption;
import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.inf.Suggest;
import com.arialyy.aria.core.upload.UTaskWrapper;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
/** /**
@ -30,12 +29,12 @@ public class HttpBuilderTarget extends AbsBuilderTarget<HttpBuilderTarget> {
private UNormalConfigHandler<HttpBuilderTarget> mConfigHandler; private UNormalConfigHandler<HttpBuilderTarget> mConfigHandler;
HttpBuilderTarget(String filePath) { HttpBuilderTarget(String filePath) {
mConfigHandler = new UNormalConfigHandler<>(this, -1); mConfigHandler = new UNormalConfigHandler<>(this, -1);
mConfigHandler.setFilePath(filePath); mConfigHandler.setFilePath(filePath);
//http暂时不支持断点上传 //http暂时不支持断点上传
getTaskWrapper().setSupportBP(false); getTaskWrapper().setSupportBP(false);
getTaskWrapper().setRequestType(AbsTaskWrapper.U_HTTP); 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() { public HttpBuilderTarget forceUpload() {
((UTaskWrapper) getTaskWrapper()).setForceUpload(true); getTaskWrapper().setIgnoreFilePathOccupy(true);
return this; return this;
} }
} }

@ -33,6 +33,7 @@ public class HttpNormalTarget extends AbsNormalTarget<HttpNormalTarget> {
mConfigHandler = new UNormalConfigHandler<>(this, taskId); mConfigHandler = new UNormalConfigHandler<>(this, taskId);
getTaskWrapper().setSupportBP(false); getTaskWrapper().setSupportBP(false);
getTaskWrapper().setRequestType(AbsTaskWrapper.U_HTTP); 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/543#issuecomment-559733124
- fix bug https://github.com/AriaLyy/Aria/issues/542 - fix bug https://github.com/AriaLyy/Aria/issues/542
- fix bug https://github.com/AriaLyy/Aria/issues/547 - fix bug https://github.com/AriaLyy/Aria/issues/547
- 修复下载失败时,中断重试无效的问题 - 修复下载失败时,中断重试无效的问题
- 增加忽略权限检查的api,`ignoreCheckPermissions()` - 增加忽略权限检查的api,`ignoreCheckPermissions()`
- 增加通用的的忽略文件路径被占用的api,`isIgnoreFilePathOccupy()`
+ v_3.7.9 (2019/11/28) + v_3.7.9 (2019/11/28)
- fix bug https://github.com/AriaLyy/Aria/issues/537 - fix bug https://github.com/AriaLyy/Aria/issues/537
+ v_3.7.8 (2019/11/28) + 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.setConvertFileSize(CommonUtil.formatFileSize(ftpFile.getSize()));
entity.setFileSize(ftpFile.getSize()); entity.setFileSize(ftpFile.getSize());
//if(CheckUtil.checkDownloadPathConflicts(mTaskWrapper.is)) //if(CheckUtil.checkDPathConflicts(mTaskWrapper.is))
entity.insert(); entity.insert();

@ -54,11 +54,6 @@ public class DTaskWrapper extends AbsTaskWrapper<DownloadEntity> {
*/ */
private String mTempFilePath; private String mTempFilePath;
/**
* {@code true}强制下载不考虑文件路径是否被占用
*/
private boolean forceDownload = false;
public DTaskWrapper(DownloadEntity entity) { public DTaskWrapper(DownloadEntity entity) {
super(entity); super(entity);
} }
@ -124,12 +119,4 @@ public class DTaskWrapper extends AbsTaskWrapper<DownloadEntity> {
public void setTempFilePath(String mTempFilePath) { public void setTempFilePath(String mTempFilePath) {
this.mTempFilePath = 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; private String tempUrl;
/**
* 如果文件路径被其它任务占用设置为true时删除其它任务
*/
private boolean forceUpload = false;
public UTaskWrapper(UploadEntity entity) { public UTaskWrapper(UploadEntity entity) {
super(entity); super(entity);
} }
@ -53,14 +48,6 @@ public class UTaskWrapper extends AbsTaskWrapper<UploadEntity> {
return getEntity().getKey(); return getEntity().getKey();
} }
public boolean isForceUpload() {
return forceUpload;
}
public void setForceUpload(boolean forceUpload) {
this.forceUpload = forceUpload;
}
@Override public UploadConfig getConfig() { @Override public UploadConfig getConfig() {
return Configuration.getInstance().uploadCfg; 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.IEntity;
import com.arialyy.aria.core.inf.ITaskOption; import com.arialyy.aria.core.inf.ITaskOption;
import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.ComponentUtil; import com.arialyy.aria.util.ComponentUtil;
/** /**
@ -85,6 +84,19 @@ public abstract class AbsTaskWrapper<ENTITY extends AbsEntity>
*/ */
private TaskOptionParams optionParams = new TaskOptionParams(); 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) { public void setTaskOption(ITaskOption option) {
this.taskOption = option; this.taskOption = option;
} }

@ -18,6 +18,7 @@ package com.arialyy.aria.util;
import android.text.TextUtils; import android.text.TextUtils;
import com.arialyy.aria.core.download.DownloadEntity; 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.inf.IRecordHandler;
import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.orm.DbEntity;
@ -32,13 +33,13 @@ public class CheckUtil {
private static final String TAG = "CheckUtil"; private static final String TAG = "CheckUtil";
/** /**
* 检查和处理路径冲突 * 检查和处理下载任务的路径冲突
* *
* @param isForceDownload true如果路径冲突将删除其它任务的记录的 * @param isForceDownload true如果路径冲突将删除其它任务的记录的
* @param filePath 文件保存路径 * @param filePath 文件保存路径
* @return false 任务不再执行true 任务继续执行 * @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 (DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=?", filePath)) {
if (!isForceDownload) { if (!isForceDownload) {
ALog.e(TAG, String.format("下载失败,保存路径【%s】已经被其它任务占用,请设置其它保存路径", filePath)); ALog.e(TAG, String.format("下载失败,保存路径【%s】已经被其它任务占用,请设置其它保存路径", filePath));
@ -53,13 +54,13 @@ public class CheckUtil {
} }
/** /**
* 检查和处理路径冲突 * 检查和处理上传任务的路径冲突
* *
* @param isForceUpload true如果路径冲突将删除其它任务的记录的 * @param isForceUpload true如果路径冲突将删除其它任务的记录的
* @param filePath 文件保存路径 * @param filePath 文件保存路径
* @return false 任务不再执行true 任务继续执行 * @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 (DbEntity.checkDataExist(UploadEntity.class, "filePath=?", filePath)) {
if (!isForceUpload) { if (!isForceUpload) {
ALog.e(TAG, String.format("上传失败,文件路径【%s】已经被其它任务占用,请设置其它文件路径", filePath)); ALog.e(TAG, String.format("上传失败,文件路径【%s】已经被其它任务占用,请设置其它文件路径", filePath));
@ -73,6 +74,27 @@ public class CheckUtil {
return true; 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 * 检查成员类是否是静态和public
*/ */

@ -52,7 +52,7 @@ public class DbDataHelper {
* @param groupHash 组合任务Hash * @param groupHash 组合任务Hash
* @return 实体不存在返回null * @return 实体不存在返回null
*/ */
public static DownloadGroupEntity getDGEntity(String groupHash) { public static DownloadGroupEntity getDGEntityByHash(String groupHash) {
List<DGEntityWrapper> wrapper = List<DGEntityWrapper> wrapper =
DbEntity.findRelationData(DGEntityWrapper.class, "DownloadGroupEntity.groupHash=?", DbEntity.findRelationData(DGEntityWrapper.class, "DownloadGroupEntity.groupHash=?",
groupHash); groupHash);
@ -60,6 +60,20 @@ public class DbDataHelper {
return wrapper == null || wrapper.size() == 0 ? null : wrapper.get(0).groupEntity; 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任务实体 * 获取组合任务实体ftpDir任务实体
* *

@ -42,12 +42,28 @@ public class RecordUtil {
* @param removeFile {@code true} 无论任务是否完成都会删除记录和文件 * @param removeFile {@code true} 无论任务是否完成都会删除记录和文件
* {@code false} 如果任务已经完成则只删除记录不删除文件任务未完成记录和文件都会删除 * {@code false} 如果任务已经完成则只删除记录不删除文件任务未完成记录和文件都会删除
*/ */
public static void delGroupTaskRecord(String groupHash, boolean removeFile) { public static void delGroupTaskRecordByHash(String groupHash, boolean removeFile) {
if (TextUtils.isEmpty(groupHash)) { if (TextUtils.isEmpty(groupHash)) {
ALog.e(TAG, "删除下载任务组记录失败,groupHash为null"); ALog.e(TAG, "删除下载任务组记录失败,groupHash为null");
return; 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); delGroupTaskRecord(groupEntity, removeFile, true);
} }

@ -44,16 +44,16 @@ Aria有以下特点:
## 引入库 ## 引入库
[![license](http://img.shields.io/badge/license-Apache2.0-brightgreen.svg?style=flat)](https://github.com/AriaLyy/Aria/blob/master/LICENSE) [![license](http://img.shields.io/badge/license-Apache2.0-brightgreen.svg?style=flat)](https://github.com/AriaLyy/Aria/blob/master/LICENSE)
[![Core](https://img.shields.io/badge/Core-3.7.9-blue)](https://github.com/AriaLyy/Aria) [![Core](https://img.shields.io/badge/Core-3.7.10-blue)](https://github.com/AriaLyy/Aria)
[![Compiler](https://img.shields.io/badge/Compiler-3.7.9-blue)](https://github.com/AriaLyy/Aria) [![Compiler](https://img.shields.io/badge/Compiler-3.7.10-blue)](https://github.com/AriaLyy/Aria)
[![FtpComponent](https://img.shields.io/badge/FtpComponent-3.7.9-orange)](https://github.com/AriaLyy/Aria) [![FtpComponent](https://img.shields.io/badge/FtpComponent-3.7.10-orange)](https://github.com/AriaLyy/Aria)
[![M3U8Component](https://img.shields.io/badge/M3U8Component-3.7.9-orange)](https://github.com/AriaLyy/Aria) [![M3U8Component](https://img.shields.io/badge/M3U8Component-3.7.10-orange)](https://github.com/AriaLyy/Aria)
```java ```java
implementation 'com.arialyy.aria:core:3.7.9' implementation 'com.arialyy.aria:core:3.7.10'
annotationProcessor 'com.arialyy.aria:compiler:3.7.9' annotationProcessor 'com.arialyy.aria:compiler:3.7.10'
implementation 'com.arialyy.aria:ftpComponent:3.7.9' # 如果需要使用ftp,请增加该组件 implementation 'com.arialyy.aria:ftpComponent:3.7.10' # 如果需要使用ftp,请增加该组件
implementation 'com.arialyy.aria:m3u8Component:3.7.9' # 如果需要使用m3u8下载功能,请增加该组件 implementation 'com.arialyy.aria:m3u8Component:3.7.10' # 如果需要使用m3u8下载功能,请增加该组件
``` ```
如果出现android support依赖错误,请将 `compile 'com.arialyy.aria:core:<last-version>'`替换为 如果出现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) + v_3.7.10 (2019/12/3)
- fix bug https://github.com/AriaLyy/Aria/issues/537 - 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) [更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)

@ -96,11 +96,11 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
.loadGroup(mUrls) .loadGroup(mUrls)
.setDirPath( .setDirPath(
Environment.getExternalStorageDirectory().getPath() + "/Download/group_imgs") Environment.getExternalStorageDirectory().getPath() + "/Download/group_imgs")
.setGroupAlias("图片测试")
//.setSubFileName(getModule(GroupModule.class).getSubName2()) //.setSubFileName(getModule(GroupModule.class).getSubName2())
//.setSubFileName(getModule(GroupModule.class).getSubName()) //.setSubFileName(getModule(GroupModule.class).getSubName())
.unknownSize() .unknownSize()
.option(getHttpOption()) .option(getHttpOption())
.ignoreFilePathOccupy()
//.setFileSize(114981416) //.setFileSize(114981416)
//.updateUrls(temp) //.updateUrls(temp)
.create(); .create();

@ -45,7 +45,7 @@ task clean(type: Delete) {
ext { ext {
versionCode = 380 versionCode = 380
versionName = '3.7.10_pre_3' versionName = '3.7.10'
userOrg = 'arialyy' userOrg = 'arialyy'
groupId = 'com.arialyy.aria' groupId = 'com.arialyy.aria'
publishVersion = versionName publishVersion = versionName

Loading…
Cancel
Save