修复wait模式下,resume(true)无效问题
pull/631/head
laoyuyu 5 years ago
parent ea2e27f3e9
commit d92f1bba94
  1. 22
      Aria/src/main/java/com/arialyy/aria/core/command/StartCmd.java
  2. 2
      Aria/src/main/java/com/arialyy/aria/core/common/controller/NormalController.java
  3. 4
      Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java
  4. 4
      DEV_LOG.md
  5. 3
      FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpULoader.java
  6. 7
      HttpComponent/src/main/java/com/arialyy/aria/http/HttpRecordHandler.java
  7. 2
      HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDThreadTaskAdapter.java
  8. 6
      PublicComponent/src/main/java/com/arialyy/aria/core/common/RecordHelper.java
  9. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalLoader.java
  10. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java
  11. 3
      SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDLoader.java
  12. 3
      SFtpComponent/src/main/java/com/arialyy/aria/sftp/upload/SFtpULoader.java
  13. 6
      app/src/main/assets/aria_config.xml
  14. 4
      build.gradle

@ -29,7 +29,7 @@ import com.arialyy.aria.util.NetUtils;
*/ */
final public class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> { final public class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
private boolean newStart = false; private boolean nowStart = false;
StartCmd(T entity, int taskType) { StartCmd(T entity, int taskType) {
super(entity, taskType); super(entity, taskType);
@ -38,10 +38,10 @@ final public class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
/** /**
* 立即执行任务 * 立即执行任务
* *
* @param newStart true 立即执行任务无论执行队列是否满了 * @param nowStart true 立即执行任务无论执行队列是否满了
*/ */
public void setNewStart(boolean newStart) { public void setNowStart(boolean nowStart) {
this.newStart = newStart; this.nowStart = nowStart;
} }
@Override public void executeCmd() { @Override public void executeCmd() {
@ -82,7 +82,7 @@ final public class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
startTask(); startTask();
} }
} else { } else {
if (newStart) { if (nowStart) {
startTask(); startTask();
} else { } else {
sendWaitState(task); sendWaitState(task);
@ -92,7 +92,19 @@ final public class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
} else { } else {
//任务没执行并且执行队列中没有该任务,才认为任务没有运行中 //任务没执行并且执行队列中没有该任务,才认为任务没有运行中
if (!mQueue.taskIsRunning(task.getKey())) { if (!mQueue.taskIsRunning(task.getKey())) {
if (mod.equals(QueueMod.NOW.getTag())) {
resumeTask();
} else {
if (mQueue.getCurrentExePoolNum() < maxTaskNum) {
resumeTask();
} else {
if (nowStart) {
resumeTask(); resumeTask();
} else {
sendWaitState(task);
}
}
}
} else { } else {
ALog.w(TAG, String.format("任务【%s】已经在运行", task.getTaskName())); ALog.w(TAG, String.format("任务【%s】已经在运行", task.getTaskName()));
} }

@ -66,7 +66,7 @@ public final class NormalController extends FeatureController implements INormal
StartCmd cmd = StartCmd cmd =
(StartCmd) CmdHelper.createNormalCmd(getTaskWrapper(), NormalCmdFactory.TASK_START, (StartCmd) CmdHelper.createNormalCmd(getTaskWrapper(), NormalCmdFactory.TASK_START,
checkTaskType()); checkTaskType());
cmd.setNewStart(newStart); cmd.setNowStart(newStart);
EventMsgUtil.getDefault() EventMsgUtil.getDefault()
.post(cmd); .post(cmd);
} }

@ -113,6 +113,10 @@ public abstract class AbsTaskQueue<TASK extends AbsTask, TASK_WRAPPER extends Ab
ALog.w(TAG, "resume task fail, task is null"); ALog.w(TAG, "resume task fail, task is null");
return; return;
} }
if (mExecutePool.taskExits(task.getKey())) {
ALog.w(TAG, String.format("task【%s】running", task.getKey()));
return;
}
if (mExecutePool.size() >= getMaxTaskNum()) { if (mExecutePool.size() >= getMaxTaskNum()) {
task.getTaskWrapper().getEntity().setState(IEntity.STATE_WAIT); task.getTaskWrapper().getEntity().setState(IEntity.STATE_WAIT);
mCachePool.putTaskToFirst(task); mCachePool.putTaskToFirst(task);

@ -1,7 +1,9 @@
## 开发日志 ## 开发日志
+ v_3.8.7 + v_3.8.7
- 修复组合任务单个子任务失败后,重新恢复组合任务,组合任务状态变为完成的问题 - 修复组合任务单个子任务失败后,重新恢复组合任务,组合任务状态变为完成的问题
- 修复40x错误,会继续重试并且无法重试成功的问题 https://github.com/AriaLyy/Aria/issues/619
- 修复wait模式下,resume(true)无效问题
- 修复now模式下的一些问题 https://github.com/AriaLyy/Aria/issues/620
+ v_3.8.6 (2020/2/17) + v_3.8.6 (2020/2/17)
- fix bug https://github.com/AriaLyy/Aria/issues/608 - fix bug https://github.com/AriaLyy/Aria/issues/608
- fix bug https://github.com/AriaLyy/Aria/issues/579#issuecomment-586665035 - fix bug https://github.com/AriaLyy/Aria/issues/579#issuecomment-586665035

@ -37,6 +37,9 @@ final class FtpULoader extends NormalLoader<UTaskWrapper> {
@Override @Override
protected void startThreadTask() { protected void startThreadTask() {
if (isBreak()) {
return;
}
// 检查记录 // 检查记录
((FtpURecordHandler) mRecordHandler).setFtpFile(ftpFile); ((FtpURecordHandler) mRecordHandler).setFtpFile(ftpFile);
if (mRecordHandler.checkTaskCompleted()) { if (mRecordHandler.checkTaskCompleted()) {

@ -36,13 +36,6 @@ public final class HttpRecordHandler extends RecordHandler {
super(wrapper); super(wrapper);
} }
@Override public void onPre() {
super.onPre();
//if (getWrapper().getRequestType() == ITaskWrapper.U_HTTP) {
// RecordUtil.delTaskRecord(getEntity().getFilePath(), IRecordHandler.TYPE_UPLOAD);
//}
}
@Override public void handlerTaskRecord(TaskRecord record) { @Override public void handlerTaskRecord(TaskRecord record) {
RecordHelper helper = new RecordHelper(getWrapper(), record); RecordHelper helper = new RecordHelper(getWrapper(), record);
if (getWrapper().isSupportBP() && record.threadNum > 1) { if (getWrapper().isSupportBP() && record.threadNum > 1) {

@ -43,7 +43,7 @@ import java.util.Set;
* Created by lyy on 2017/1/18. 下载线程 * Created by lyy on 2017/1/18. 下载线程
*/ */
final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter { final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
private final String TAG = "HttpThreadTask"; private final String TAG = "HttpDThreadTaskAdapter";
private DTaskWrapper mTaskWrapper; private DTaskWrapper mTaskWrapper;
HttpDThreadTaskAdapter(SubThreadConfig config) { HttpDThreadTaskAdapter(SubThreadConfig config) {

@ -130,13 +130,17 @@ public class RecordHelper {
/* /*
* 检查记录文件 * 检查记录文件
*/ */
if (blockFileLen == threadRect) { if (blockFileLen == threadRect && blockFileLen != 0) {
ALog.i(TAG, String.format("分块【%s】已完成,更新记录", temp.getPath())); ALog.i(TAG, String.format("分块【%s】已完成,更新记录", temp.getPath()));
tr.startLocation = blockFileLen; tr.startLocation = blockFileLen;
tr.isComplete = true; tr.isComplete = true;
} else if (tr.startLocation != realLocation) { // 处理记录小于分块文件长度的情况 } else if (tr.startLocation != realLocation) { // 处理记录小于分块文件长度的情况
ALog.i(TAG, String.format("修正分块【%s】的进度记录为:%s", temp.getPath(), realLocation)); ALog.i(TAG, String.format("修正分块【%s】的进度记录为:%s", temp.getPath(), realLocation));
tr.startLocation = realLocation; tr.startLocation = realLocation;
}else {
ALog.i(TAG, String.format("修正分块【%s】的进度记录为:%s", temp.getPath(), realLocation));
tr.startLocation = realLocation;
tr.isComplete = false;
} }
} else { } else {
ALog.i(TAG, String.format("分块【%s】已完成", temp.getPath())); ALog.i(TAG, String.format("分块【%s】已完成", temp.getPath()));

@ -28,6 +28,7 @@ import com.arialyy.aria.core.manager.ThreadTaskManager;
import com.arialyy.aria.core.task.IThreadTask; import com.arialyy.aria.core.task.IThreadTask;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.exception.AriaException; import com.arialyy.aria.exception.AriaException;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.FileUtil; import com.arialyy.aria.util.FileUtil;
import java.io.File; import java.io.File;
@ -99,6 +100,9 @@ public class NormalLoader<T extends AbsTaskWrapper> extends AbsNormalLoader<T> {
} }
protected void startThreadTask() { protected void startThreadTask() {
if (isBreak()){
return;
}
if (getListener() instanceof IDLoadListener) { if (getListener() instanceof IDLoadListener) {
((IDLoadListener) getListener()).onPostPre(getEntity().getFileSize()); ((IDLoadListener) getListener()).onPostPre(getEntity().getFileSize());

@ -93,6 +93,10 @@ public final class SubLoader implements ILoader, ILoaderVisitor {
} }
private void handlerTask() { private void handlerTask() {
if (isBreak()){
return;
}
record = recordHandler.getRecord(wrapper.getEntity().getFileSize()); record = recordHandler.getRecord(wrapper.getEntity().getFileSize());
if (record.threadRecords != null if (record.threadRecords != null
&& !TextUtils.isEmpty(record.filePath) && !TextUtils.isEmpty(record.filePath)

@ -87,6 +87,9 @@ final class SFtpDLoader extends AbsNormalLoader<DTaskWrapper> {
} }
private void startThreadTask() { private void startThreadTask() {
if (isBreak()) {
return;
}
if (getListener() instanceof IDLoadListener) { if (getListener() instanceof IDLoadListener) {
((IDLoadListener) getListener()).onPostPre(getEntity().getFileSize()); ((IDLoadListener) getListener()).onPostPre(getEntity().getFileSize());

@ -86,6 +86,9 @@ final class SFtpULoader extends AbsNormalLoader<UTaskWrapper> {
} }
private void startThreadTask(SftpATTRS attrs) { private void startThreadTask(SftpATTRS attrs) {
if (isBreak()) {
return;
}
if (getListener() instanceof IDLoadListener) { if (getListener() instanceof IDLoadListener) {
((IDLoadListener) getListener()).onPostPre(getEntity().getFileSize()); ((IDLoadListener) getListener()).onPostPre(getEntity().getFileSize());

@ -22,7 +22,7 @@
<download> <download>
<!--设置任务最大下载速度,0表示不限速,单位为:kb--> <!--设置任务最大下载速度,0表示不限速,单位为:kb-->
<maxSpeed value="0"/> <maxSpeed value="200"/>
<!-- <!--
多线程下载是否使用块下载模式,{@code true}使用,{@code false}不使用 多线程下载是否使用块下载模式,{@code true}使用,{@code false}不使用
@ -44,7 +44,7 @@
<threadNum value="3"/> <threadNum value="3"/>
<!--设置下载队列最大任务数, 默认为2--> <!--设置下载队列最大任务数, 默认为2-->
<maxTaskNum value="1"/> <maxTaskNum value="2"/>
<!--设置下载失败,重试次数,默认为10--> <!--设置下载失败,重试次数,默认为10-->
<reTryNum value="5"/> <reTryNum value="5"/>
@ -68,7 +68,7 @@
<convertSpeed value="true"/> <convertSpeed value="true"/>
<!--执行队列类型,见com.arialyy.aria.core.QueueMod,默认类型为wait--> <!--执行队列类型,见com.arialyy.aria.core.QueueMod,默认类型为wait-->
<queueMod value="wait"/> <queueMod value="now"/>
<!--进度更新更新间隔,默认1000毫秒--> <!--进度更新更新间隔,默认1000毫秒-->
<updateInterval value="1000"/> <updateInterval value="1000"/>

@ -44,8 +44,8 @@ task clean(type: Delete) {
} }
ext { ext {
versionCode = 386 versionCode = 387
versionName = '3.8.6' versionName = '3.8.7-beta-1'
userOrg = 'arialyy' userOrg = 'arialyy'
groupId = 'com.arialyy.aria' groupId = 'com.arialyy.aria'
publishVersion = versionName publishVersion = versionName

Loading…
Cancel
Save