From 14901d4c0c1b77b0ab46f86507caca348ffd4322 Mon Sep 17 00:00:00 2001 From: DaveBoy1994 Date: Thu, 5 Mar 2020 13:38:14 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=BB=84=E5=90=88=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=AD=90=E4=BB=BB=E5=8A=A1=E5=A4=B1=E8=B4=A5Exception=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/arialyy/aria/core/listener/DownloadGroupListener.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/listener/DownloadGroupListener.java b/PublicComponent/src/main/java/com/arialyy/aria/core/listener/DownloadGroupListener.java index 511e6916..9af247ec 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/listener/DownloadGroupListener.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/listener/DownloadGroupListener.java @@ -30,6 +30,8 @@ import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.ErrorHelp; import com.arialyy.aria.util.RecordUtil; +import static com.arialyy.aria.core.task.AbsTask.ERROR_INFO_KEY; + /** * Created by Aria.Lao on 2017/7/20. 任务组下载事件 */ @@ -85,6 +87,7 @@ public class DownloadGroupListener handleSubSpeed(subEntity, 0); saveSubState(IEntity.STATE_FAIL, subEntity); saveCurrentLocation(); + mSeedEntity.groupTask.putExpand(ERROR_INFO_KEY,e); sendInState2Target(ISchedulers.SUB_FAIL, subEntity); if (e != null) { e.printStackTrace(); From 41088dfa237558ca5b87137491df5949d3f825cf Mon Sep 17 00:00:00 2001 From: DaveBoy1994 Date: Thu, 5 Mar 2020 14:00:28 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E4=B8=AD=E5=8D=95=E4=B8=AA=E4=BB=BB=E5=8A=A1=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=A4=B1=E8=B4=A5=E5=90=8E=EF=BC=8C=E6=9C=80=E7=BB=88?= =?UTF-8?q?=E7=BB=84=E4=BB=BB=E5=8A=A1=E5=9B=9E=E8=B0=83stop/fail=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arialyy/aria/core/config/DGroupConfig.java | 15 +++++++++++++++ .../com/arialyy/aria/core/config/XMLReader.java | 4 ++++ .../arialyy/aria/core/group/SimpleSchedulers.java | 3 +++ app/src/main/assets/aria_config.xml | 3 ++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/config/DGroupConfig.java b/PublicComponent/src/main/java/com/arialyy/aria/core/config/DGroupConfig.java index 17989d3c..c99ab3e9 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/config/DGroupConfig.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/config/DGroupConfig.java @@ -31,6 +31,11 @@ public class DGroupConfig extends BaseTaskConfig implements Serializable { */ int subMaxTaskNum = 3; + /** + * 子任务失败时回调stop,默认true + */ + private boolean subFailAsStop = true; + /** * 子任务重试次数,默认为5 */ @@ -118,4 +123,14 @@ public class DGroupConfig extends BaseTaskConfig implements Serializable { save(); return this; } + + public boolean isSubFailAsStop() { + return subFailAsStop; + } + + public DGroupConfig setSubFailAsStop(boolean subFailAsStop) { + this.subFailAsStop = subFailAsStop; + save(); + return this; + } } \ No newline at end of file diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/config/XMLReader.java b/PublicComponent/src/main/java/com/arialyy/aria/core/config/XMLReader.java index f4dfbd84..0e25c6f1 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/config/XMLReader.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/config/XMLReader.java @@ -144,6 +144,10 @@ public class XMLReader extends DefaultHandler { int subMaxTaskNum = checkInt(value) ? Integer.parseInt(value) : 3; setField("subMaxTaskNum", subMaxTaskNum, ConfigType.D_GROUP); break; + case "subFailAsStop": // 子任务失败时回调stop + setField("subFailAsStop", checkBoolean(value) ? Boolean.valueOf(value) : false, + ConfigType.D_GROUP); + break; case "subReTryNum": // 子任务重试次数 int subReTryNum = checkInt(value) ? Integer.parseInt(value) : 5; setField("subReTryNum", subReTryNum, ConfigType.D_GROUP); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java b/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java index a84d59f6..65e3782e 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java @@ -179,6 +179,9 @@ final class SimpleSchedulers implements Handler.Callback { == mGState.getSubSize()) { if (mGState.getStopNum() == 0 && mGState.getFailNum() == 0) { mGState.listener.onComplete(); + } else if(mGState.getStopNum() == 0&&!Configuration.getInstance().dGroupCfg.isSubFailAsStop() ){ + mGState.listener.onFail(false, new AriaException(TAG, + String.format("任务组【%s】下载失败", mGState.getGroupHash()))); } else { mGState.listener.onStop(mGState.getProgress()); } diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml index 4f373352..111809df 100644 --- a/app/src/main/assets/aria_config.xml +++ b/app/src/main/assets/aria_config.xml @@ -126,7 +126,8 @@ - + + From a65b2e31f9a9f76ee76a4aeea78676b6e2771800 Mon Sep 17 00:00:00 2001 From: DaveBoy1994 Date: Fri, 13 Mar 2020 10:40:33 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=B8=AD=3F=E5=90=8E=E9=9D=A2=E5=AD=98?= =?UTF-8?q?=E5=9C=A8/=E5=AF=BC=E8=87=B4=E7=9A=84=E5=B4=A9=E6=BA=83?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/arialyy/aria/util/DbDataHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PublicComponent/src/main/java/com/arialyy/aria/util/DbDataHelper.java b/PublicComponent/src/main/java/com/arialyy/aria/util/DbDataHelper.java index bf4d306e..8a2fabf1 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/util/DbDataHelper.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/util/DbDataHelper.java @@ -107,8 +107,8 @@ public class DbDataHelper { int lastIndex = url.lastIndexOf(File.separator); //去除url末尾携带的的参数 int endIndex = url.lastIndexOf("?"); - if(endIndex<0)endIndex=url.length(); + if(endIndex<0||endIndex Date: Thu, 19 Mar 2020 09:26:48 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=9B=9E=E8=B0=83stop/fa?= =?UTF-8?q?il=E8=AE=BE=E7=BD=AE=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/arialyy/aria/core/group/SimpleSchedulers.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java b/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java index 8808703c..9daa5765 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java @@ -122,7 +122,7 @@ final class SimpleSchedulers implements Handler.Callback { == mGState.getSubSize()) { mQueue.clear(); mGState.isRunning.set(false); - if (mGState.getCompleteNum() > 0) { + if (mGState.getCompleteNum() > 0&&Configuration.getInstance().dGroupCfg.isSubFailAsStop()) { ALog.e(TAG, String.format("任务组【%s】停止", mGState.getGroupHash())); mGState.listener.onStop(mGState.getProgress()); } else {