- 修复组任务,其中一个子任务在获取文件长度失败后,重新恢复组合任务,组合任务状态变为完成的问题 https://github.com/AriaLyy/Aria/issues/628

pull/640/head
laoyuyu 5 years ago
parent 54cbdb7ee0
commit 669ac6b09c
  1. 1
      DEV_LOG.md
  2. 24
      HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGInfoTask.java
  3. 7
      HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGLoader.java
  4. 54
      M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java
  5. 27
      M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/VodStateManager.java
  6. 8
      PublicComponent/src/main/java/com/arialyy/aria/core/common/RecordHelper.java
  7. 10
      PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java
  8. 33
      PublicComponent/src/main/java/com/arialyy/aria/core/group/GroupRunState.java
  9. 15
      PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java
  10. 30
      PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalThreadStateManager.java
  11. 2
      PublicComponent/src/main/java/com/arialyy/aria/orm/DelegateFind.java
  12. 4
      app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java
  13. 10
      app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java
  14. 3
      app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java
  15. 2
      build.gradle

@ -4,6 +4,7 @@
- 修复40x错误,会继续重试并且无法重试成功的问题 https://github.com/AriaLyy/Aria/issues/619
- 修复wait模式下,resume(true)无效问题
- 修复now模式下的一些问题 https://github.com/AriaLyy/Aria/issues/620
- 修复组任务,其中一个子任务在获取文件长度失败后,重新恢复组合任务,组合任务状态变为完成的问题 https://github.com/AriaLyy/Aria/issues/628
+ v_3.8.6 (2020/2/17)
- fix bug https://github.com/AriaLyy/Aria/issues/608
- fix bug https://github.com/AriaLyy/Aria/issues/579#issuecomment-586665035

@ -30,6 +30,7 @@ import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 组合任务文件信息用于获取长度未知时组合任务的长度
@ -41,8 +42,8 @@ public final class HttpDGInfoTask implements IInfoTask {
private final Object LOCK = new Object();
private ExecutorService mPool = null;
private boolean getLenComplete = false;
private int count;
private int failCount;
private AtomicInteger count = new AtomicInteger();
private AtomicInteger failCount = new AtomicInteger();
private DownloadGroupListener listener;
/**
@ -50,18 +51,18 @@ public final class HttpDGInfoTask implements IInfoTask {
*/
private Callback subCallback = new Callback() {
@Override public void onSucceed(String url, CompleteInfo info) {
count++;
checkGetSizeComplete(count, failCount);
count.getAndIncrement();
checkGetSizeComplete(count.get(), failCount.get());
ALog.d(TAG, "获取子任务信息完成");
}
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
ALog.e(TAG, String.format("获取文件信息失败,url:%s", ((DownloadEntity) entity).getUrl()));
count++;
failCount++;
count.getAndIncrement();
failCount.getAndIncrement();
listener.onSubFail((DownloadEntity) entity, new AriaHTTPException(TAG,
String.format("子任务获取文件长度失败,url:%s", ((DownloadEntity) entity).getUrl())));
checkGetSizeComplete(count, failCount);
checkGetSizeComplete(count.get(), failCount.get());
}
};
@ -79,7 +80,7 @@ public final class HttpDGInfoTask implements IInfoTask {
return;
}
// 处理组合任务大小未知的情况
if (wrapper.isUnknownSize() && wrapper.getEntity().getFileSize() < 1) {
if (wrapper.isUnknownSize()) {
mPool = Executors.newCachedThreadPool();
getGroupSize();
try {
@ -89,7 +90,7 @@ public final class HttpDGInfoTask implements IInfoTask {
} catch (InterruptedException e) {
e.printStackTrace();
}
if (!mPool.isShutdown()){
if (!mPool.isShutdown()) {
mPool.shutdown();
}
} else {
@ -107,6 +108,10 @@ public final class HttpDGInfoTask implements IInfoTask {
new Thread(new Runnable() {
@Override public void run() {
for (DTaskWrapper dTaskWrapper : wrapper.getSubTaskWrapper()) {
if (dTaskWrapper.getEntity().getFileSize() > 0) {
count.getAndIncrement();
continue;
}
cloneHeader(dTaskWrapper);
HttpDFileInfoTask infoTask = new HttpDFileInfoTask(dTaskWrapper);
infoTask.setCallback(subCallback);
@ -158,7 +163,6 @@ public final class HttpDGInfoTask implements IInfoTask {
subOption.setFileNameAdapter(groupOption.getFileNameAdapter());
subOption.setUseServerFileName(groupOption.isUseServerFileName());
subOption.setFileNameAdapter(groupOption.getFileNameAdapter());
subOption.setRequestEnum(groupOption.getRequestEnum());
subOption.setHeaders(groupOption.getHeaders());

@ -26,6 +26,7 @@ import com.arialyy.aria.core.listener.DownloadGroupListener;
import com.arialyy.aria.core.loader.IInfoTask;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.exception.AriaException;
import java.io.File;
/**
* http 组合任务加载器
@ -53,6 +54,12 @@ final class HttpDGLoader extends AbsGroupLoader {
}
onPostStart();
for (DTaskWrapper wrapper : getWrapper().getSubTaskWrapper()) {
File subFile = new File(wrapper.getEntity().getFilePath());
if (wrapper.getEntity().getFileSize() > 0
&& subFile.exists()
&& subFile.length() == wrapper.getEntity().getFileSize()) {
continue;
}
DownloadEntity dEntity = wrapper.getEntity();
startSubLoader(createSubLoader(wrapper, dEntity.getFileSize() < 0));
}

@ -51,6 +51,7 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
@ -75,10 +76,11 @@ final class M3U8VodLoader extends BaseM3U8Loader {
private SparseArray<ThreadRecord> mAfterPeer = new SparseArray<>();
private PeerIndexEvent mCurrentEvent;
private String mCacheDir;
private int aIndex = 0, bIndex = 0;
private int mCurrentFlagSize;
private AtomicInteger afterPeerIndex = new AtomicInteger();
private AtomicInteger beforePeerIndex = new AtomicInteger();
private AtomicInteger mCompleteNum = new AtomicInteger();
private AtomicInteger mCurrentFlagSize = new AtomicInteger();
private boolean isJump = false, isDestroy = false;
private int mCompleteNum = 0;
private ExecutorService mJumpThreadPool;
private Thread jumpThread = null;
private M3U8TaskOption mM3U8Option;
@ -102,20 +104,20 @@ final class M3U8VodLoader extends BaseM3U8Loader {
}
int getCompleteNum() {
return mCompleteNum;
return mCompleteNum.get();
}
void setCompleteNum(int mCompleteNum) {
this.mCompleteNum = mCompleteNum;
void setCompleteNum(int completeNum) {
mCompleteNum.set(completeNum);
}
int getCurrentFlagSize() {
mCurrentFlagSize = mFlagQueue.size();
return mCurrentFlagSize;
mCurrentFlagSize.set(mFlagQueue.size());
return mCurrentFlagSize.get();
}
void setCurrentFlagSize(int currentFlagSize) {
mCurrentFlagSize = currentFlagSize;
mCurrentFlagSize.set(currentFlagSize);
}
boolean isJump() {
@ -178,7 +180,7 @@ final class M3U8VodLoader extends BaseM3U8Loader {
try {
LOCK.lock();
while (mFlagQueue.size() < EXEC_MAX_NUM && !isBreak()) {
if (mCompleteNum == mRecord.threadRecords.size()) {
if (mCompleteNum.get() == mRecord.threadRecords.size()) {
break;
}
@ -214,16 +216,18 @@ final class M3U8VodLoader extends BaseM3U8Loader {
ThreadRecord tr = null;
try {
// 优先下载peer指针之后的数据
if (bIndex == 0 && aIndex < mAfterPeer.size()) {
if (beforePeerIndex.get() == 0 && afterPeerIndex.get() < mAfterPeer.size()) {
//ALog.d(TAG, String.format("afterArray size:%s, index:%s", mAfterPeer.size(), aIndex));
tr = mAfterPeer.valueAt(aIndex);
aIndex++;
tr = mAfterPeer.valueAt(afterPeerIndex.get());
afterPeerIndex.getAndIncrement();
}
// 如果指针之后的数组没有切片了,则重新初始化指针位置,并获取指针之前的数组获取切片进行下载
if (mBeforePeer.size() > 0 && (tr == null || bIndex != 0) && bIndex < mBeforePeer.size()) {
tr = mBeforePeer.valueAt(bIndex);
bIndex++;
if (mBeforePeer.size() > 0
&& (tr == null || beforePeerIndex.get() != 0)
&& beforePeerIndex.get() < mBeforePeer.size()) {
tr = mBeforePeer.valueAt(beforePeerIndex.get());
beforePeerIndex.getAndIncrement();
}
} catch (Exception e) {
e.printStackTrace();
@ -256,19 +260,19 @@ final class M3U8VodLoader extends BaseM3U8Loader {
return;
}
// 设置需要下载的切片
mCompleteNum = 0;
mCompleteNum.set(0);
for (ThreadRecord tr : mRecord.threadRecords) {
if (!tr.isComplete) {
mAfterPeer.put(tr.threadId, tr);
} else {
mCompleteNum++;
mCompleteNum.getAndIncrement();
}
}
getStateManager().updateStateCount();
if (mCompleteNum <= 0) {
if (mCompleteNum.get() <= 0) {
getListener().onStart(0);
} else {
int percent = mCompleteNum * 100 / mRecord.threadRecords.size();
int percent = mCompleteNum.get() * 100 / mRecord.threadRecords.size();
getListener().onResume(percent);
}
}
@ -329,7 +333,7 @@ final class M3U8VodLoader extends BaseM3U8Loader {
isJump = true;
notifyWaitLock(false);
mCurrentFlagSize = mFlagQueue.size();
mCurrentFlagSize.set(mFlagQueue.size());
// 停止所有正在执行的线程任务
try {
TempFlag flag;
@ -403,12 +407,12 @@ final class M3U8VodLoader extends BaseM3U8Loader {
mBeforePeer.clear();
mAfterPeer.clear();
mFlagQueue.clear();
aIndex = 0;
bIndex = 0;
mCompleteNum = 0;
afterPeerIndex.set(0);
beforePeerIndex.set(0);
mCompleteNum.set(0);
for (ThreadRecord tr : mRecord.threadRecords) {
if (tr.isComplete) {
mCompleteNum++;
mCompleteNum.getAndIncrement();
continue;
}
if (tr.threadId < mCurrentEvent.peerIndex) {

@ -29,8 +29,8 @@ import com.arialyy.aria.core.loader.ILoaderVisitor;
import com.arialyy.aria.core.manager.ThreadTaskManager;
import com.arialyy.aria.core.processor.ITsMergeHandler;
import com.arialyy.aria.core.task.ThreadTask;
import com.arialyy.aria.exception.AriaM3U8Exception;
import com.arialyy.aria.exception.AriaException;
import com.arialyy.aria.exception.AriaM3U8Exception;
import com.arialyy.aria.m3u8.BaseM3U8Loader;
import com.arialyy.aria.m3u8.M3U8Listener;
import com.arialyy.aria.m3u8.M3U8TaskOption;
@ -40,6 +40,7 @@ import com.arialyy.aria.util.FileUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
/**
* m3u8 点播下载状态管理器
@ -49,9 +50,9 @@ public final class VodStateManager implements IThreadStateManager {
private M3U8Listener listener;
private int startThreadNum; // 启动的线程总数
private int cancelNum = 0; // 已经取消的线程的数
private int stopNum = 0; // 已经停止的线程数
private int failNum = 0; // 失败的线程数
private AtomicInteger cancelNum = new AtomicInteger(0); // 已经取消的线程的数
private AtomicInteger stopNum = new AtomicInteger(0); // 已经停止的线程数
private AtomicInteger failNum = new AtomicInteger(0); // 失败的线程数
private long progress;
private TaskRecord taskRecord; // 任务记录
private Looper looper;
@ -74,11 +75,11 @@ public final class VodStateManager implements IThreadStateManager {
int peerIndex = msg.getData().getInt(ISchedulers.DATA_M3U8_PEER_INDEX);
switch (msg.what) {
case STATE_STOP:
stopNum++;
stopNum.getAndIncrement();
removeSignThread((ThreadTask) msg.obj);
// 处理跳转位置后,恢复任务
if (loader.isJump()
&& (stopNum == loader.getCurrentFlagSize() || loader.getCurrentFlagSize() == 0)
&& (stopNum.get() == loader.getCurrentFlagSize() || loader.getCurrentFlagSize() == 0)
&& !loader.isBreak()) {
loader.resumeTask();
return true;
@ -90,7 +91,7 @@ public final class VodStateManager implements IThreadStateManager {
}
break;
case STATE_CANCEL:
cancelNum++;
cancelNum.getAndIncrement();
removeSignThread((ThreadTask) msg.obj);
if (loader.isBreak()) {
@ -99,7 +100,7 @@ public final class VodStateManager implements IThreadStateManager {
}
break;
case STATE_FAIL:
failNum++;
failNum.getAndIncrement();
for (ThreadRecord tr : taskRecord.threadRecords) {
if (tr.threadId == peerIndex) {
loader.getBeforePeer().put(peerIndex, tr);
@ -175,9 +176,9 @@ public final class VodStateManager implements IThreadStateManager {
};
void updateStateCount() {
cancelNum = 0;
stopNum = 0;
failNum = 0;
cancelNum.set(0);
stopNum.set(0);
failNum.set(0);
}
@Override public void setLooper(TaskRecord taskRecord, Looper looper) {
@ -233,12 +234,12 @@ public final class VodStateManager implements IThreadStateManager {
@Override public boolean isFail() {
printInfo("isFail");
return failNum != 0 && failNum == loader.getCurrentFlagSize() && !loader.isJump();
return failNum.get() != 0 && failNum.get() == loader.getCurrentFlagSize() && !loader.isJump();
}
@Override public boolean isComplete() {
if (m3U8Option.isIgnoreFailureTs()) {
return loader.getCompleteNum() + failNum >= taskRecord.threadRecords.size()
return loader.getCompleteNum() + failNum.get() >= taskRecord.threadRecords.size()
&& !loader.isJump();
} else {
return loader.getCompleteNum() == taskRecord.threadRecords.size() && !loader.isJump();

@ -137,7 +137,7 @@ public class RecordHelper {
} else if (tr.startLocation != realLocation) { // 处理记录小于分块文件长度的情况
ALog.i(TAG, String.format("修正分块【%s】的进度记录为:%s", temp.getPath(), realLocation));
tr.startLocation = realLocation;
}else {
} else {
ALog.i(TAG, String.format("修正分块【%s】的进度记录为:%s", temp.getPath(), realLocation));
tr.startLocation = realLocation;
tr.isComplete = false;
@ -163,8 +163,10 @@ public class RecordHelper {
// 目标文件
File targetFile = new File(mTaskRecord.filePath);
// 处理组合任务其中一个子任务完成的情况
if (tr.isComplete && targetFile.exists() && targetFile.length() == mWrapper.getEntity()
.getFileSize()) {
if (tr.isComplete
&& targetFile.exists()
&& targetFile.length() != 0
&& targetFile.length() == mWrapper.getEntity().getFileSize()) {
tr.isComplete = true;
} else {
ALog.w(TAG, String.format("文件【%s】不存在,任务将重新开始", file.getPath()));

@ -153,7 +153,7 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader {
if (!checkSubTask(url, "开始")) {
return;
}
if (!mState.isRunning) {
if (!mState.isRunning.get()) {
startTimer();
}
AbsSubDLoadUtil d = getDownloader(url, false);
@ -212,7 +212,7 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader {
}
@Override public boolean isRunning() {
return mState != null && mState.isRunning;
return mState != null && mState.isRunning.get();
}
@Override public void cancel() {
@ -275,11 +275,11 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader {
}
private synchronized void startTimer() {
mState.isRunning = true;
mState.isRunning.set(true);
mTimer = new ScheduledThreadPoolExecutor(1);
mTimer.scheduleWithFixedDelay(new Runnable() {
@Override public void run() {
if (!mState.isRunning) {
if (!mState.isRunning.get()) {
closeTimer();
} else if (mCurrentLocation >= 0) {
long t = 0;
@ -321,7 +321,7 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader {
}
}
protected void fail(AriaException e, boolean needRetry){
protected void fail(AriaException e, boolean needRetry) {
closeTimer();
getListener().onFail(needRetry, e);
}

@ -19,6 +19,8 @@ import com.arialyy.aria.core.listener.IDGroupListener;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 组合任务执行中的状态信息
@ -32,17 +34,18 @@ public final class GroupRunState {
/**
* 已经完成的任务数
*/
private int mCompleteNum;
private AtomicInteger mCompleteNum = new AtomicInteger();
/**
* 失败的任务数
*/
private int mFailNum;
private AtomicInteger mFailNum = new AtomicInteger();
/**
* 停止的任务数
*/
private int mStopNum;
private AtomicInteger mStopNum = new AtomicInteger();
;
/**
* 当前进度
@ -62,7 +65,7 @@ public final class GroupRunState {
/**
* 是否在执行
*/
boolean isRunning = false;
AtomicBoolean isRunning = new AtomicBoolean(false);
/**
* 子任务失败停止记录用于当子任务失败重新被用户点击开始时更新{@link #mStopNum}{@link #mFailNum}
@ -78,7 +81,7 @@ public final class GroupRunState {
mGroupHash = groupHash;
}
public void setSubSize(int subSize){
public void setSubSize(int subSize) {
mSubSize = subSize;
}
@ -88,11 +91,11 @@ public final class GroupRunState {
* @return {@code true}组合任务正在执行
*/
public boolean isRunning() {
return isRunning;
return isRunning.get();
}
public void setRunning(boolean running) {
isRunning = running;
isRunning.set(running);
}
String getGroupHash() {
@ -110,21 +113,21 @@ public final class GroupRunState {
* 获取失败的数量
*/
public int getFailNum() {
return mFailNum;
return mFailNum.get();
}
/**
* 获取停止的数量
*/
public int getStopNum() {
return mStopNum;
return mStopNum.get();
}
/**
* 获取完成的数量
*/
public int getCompleteNum() {
return mCompleteNum;
return mCompleteNum.get();
}
/**
@ -138,7 +141,7 @@ public final class GroupRunState {
* 更新完成的数量mCompleteNum + 1
*/
public void updateCompleteNum() {
mCompleteNum++;
mCompleteNum.getAndIncrement();
}
/**
@ -156,10 +159,10 @@ public final class GroupRunState {
public void updateCount(String key) {
if (mFailTemp.contains(key)) {
mFailTemp.remove(key);
mFailNum--;
mFailNum.getAndDecrement();
} else if (mStopTemp.contains(key)) {
mStopTemp.remove(key);
mStopNum--;
mStopNum.getAndDecrement();
}
}
@ -170,7 +173,7 @@ public final class GroupRunState {
*/
public void countStopNum(String key) {
mStopTemp.add(key);
mStopNum++;
mStopNum.getAndIncrement();
}
/**
@ -180,6 +183,6 @@ public final class GroupRunState {
*/
public void countFailNum(String key) {
mFailTemp.add(key);
mFailNum++;
mFailNum.getAndIncrement();
}
}

@ -121,9 +121,14 @@ final class SimpleSchedulers implements Handler.Callback {
|| mGState.getStopNum() + mGState.getFailNum() + mGState.getCompleteNum()
== mGState.getSubSize()) {
mQueue.clear();
mGState.isRunning = false;
mGState.listener.onFail(false, new AriaException(TAG,
String.format("任务组【%s】下载失败", mGState.getGroupHash())));
mGState.isRunning.set(false);
if (mGState.getCompleteNum() > 0) {
ALog.e(TAG, String.format("任务组【%s】停止", mGState.getGroupHash()));
mGState.listener.onStop(mGState.getProgress());
} else {
mGState.listener.onFail(false, new AriaException(TAG,
String.format("任务组【%s】下载失败", mGState.getGroupHash())));
}
} else {
startNext();
}
@ -147,7 +152,7 @@ final class SimpleSchedulers implements Handler.Callback {
+ mQueue.getCacheSize()
== mGState.getSubSize()) {
mQueue.clear();
mGState.isRunning = false;
mGState.isRunning.set(false);
mGState.listener.onStop(mGState.getProgress());
} else {
startNext();
@ -183,7 +188,7 @@ final class SimpleSchedulers implements Handler.Callback {
mGState.listener.onStop(mGState.getProgress());
}
mQueue.clear();
mGState.isRunning = false;
mGState.isRunning.set(false);
} else {
startNext();
}

@ -24,26 +24,28 @@ import com.arialyy.aria.core.inf.IThreadStateManager;
import com.arialyy.aria.core.listener.IEventListener;
import com.arialyy.aria.exception.AriaException;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.FileUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
/**
* 线程任务管理器用于处理多线程下载时任务的状态回调
*/
public class NormalThreadStateManager implements IThreadStateManager {
private final String TAG = "ThreadTaskStateManager";
private final String TAG = CommonUtil.getClassName(this);
/**
* 任务状态回调
*/
private IEventListener mListener;
private int mThreadNum; // 启动的线程总数
private int mCancelNum = 0; // 已经取消的线程的数
private int mStopNum = 0; // 已经停止的线程数
private int mFailNum = 0; // 失败的线程数
private int mCompleteNum = 0; // 完成的线程数
private AtomicInteger mCancelNum = new AtomicInteger(0); // 已经取消的线程的数
private AtomicInteger mStopNum = new AtomicInteger(0); // 已经停止的线程数
private AtomicInteger mFailNum = new AtomicInteger(0); // 失败的线程数
private AtomicInteger mCompleteNum = new AtomicInteger(0); // 完成的线程数
private long mProgress; //当前总进度
private TaskRecord mTaskRecord; // 任务记录
private Looper mLooper;
@ -75,19 +77,19 @@ public class NormalThreadStateManager implements IThreadStateManager {
checkLooper();
switch (msg.what) {
case STATE_STOP:
mStopNum++;
mStopNum.getAndIncrement();
if (isStop()) {
quitLooper();
}
break;
case STATE_CANCEL:
mCancelNum++;
mCancelNum.getAndIncrement();
if (isCancel()) {
quitLooper();
}
break;
case STATE_FAIL:
mFailNum++;
mFailNum.getAndIncrement();
if (isFail()) {
Bundle b = msg.getData();
mListener.onFail(b.getBoolean(DATA_RETRY, false),
@ -96,7 +98,7 @@ public class NormalThreadStateManager implements IThreadStateManager {
}
break;
case STATE_COMPLETE:
mCompleteNum++;
mCompleteNum.getAndIncrement();
if (isComplete()) {
ALog.d(TAG, "isComplete, completeNum = " + mCompleteNum);
//if (mTaskRecord.taskType == ITaskWrapper.D_SFTP) {
@ -168,7 +170,7 @@ public class NormalThreadStateManager implements IThreadStateManager {
//ALog.d(TAG,
// String.format("isStop; stopNum: %s, cancelNum: %s, failNum: %s, completeNum: %s", mStopNum,
// mCancelNum, mFailNum, mCompleteNum));
return mStopNum == mThreadNum || mStopNum + mCompleteNum == mThreadNum;
return mStopNum.get() == mThreadNum || mStopNum.get() + mCompleteNum.get() == mThreadNum;
}
/**
@ -179,8 +181,8 @@ public class NormalThreadStateManager implements IThreadStateManager {
//ALog.d(TAG,
// String.format("isFail; stopNum: %s, cancelNum: %s, failNum: %s, completeNum: %s", mStopNum,
// mCancelNum, mFailNum, mCompleteNum));
return mCompleteNum != mThreadNum
&& (mFailNum == mThreadNum || mFailNum + mCompleteNum == mThreadNum);
return mCompleteNum.get() != mThreadNum
&& (mFailNum.get() == mThreadNum || mFailNum.get() + mCompleteNum.get() == mThreadNum);
}
/**
@ -192,7 +194,7 @@ public class NormalThreadStateManager implements IThreadStateManager {
// String.format("isComplete; stopNum: %s, cancelNum: %s, failNum: %s, completeNum: %s",
// mStopNum,
// mCancelNum, mFailNum, mCompleteNum));
return mCompleteNum == mThreadNum;
return mCompleteNum.get() == mThreadNum;
}
/**
@ -202,7 +204,7 @@ public class NormalThreadStateManager implements IThreadStateManager {
//ALog.d(TAG, String.format("isCancel; stopNum: %s, cancelNum: %s, failNum: %s, completeNum: %s",
// mStopNum,
// mCancelNum, mFailNum, mCompleteNum));
return mCancelNum == mThreadNum;
return mCancelNum.get() == mThreadNum;
}
/**

@ -98,7 +98,7 @@ class DelegateFind extends AbsDelegate {
*/
<T extends AbsDbWrapper> List<T> findRelationData(SQLiteDatabase db, Class<T> clazz,
String... expression) {
return exeRelationSql(db, clazz, 1, 10, expression);
return exeRelationSql(db, clazz, 1, Integer.MAX_VALUE, expression);
}
/**

@ -89,7 +89,9 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
}
@Override public void resume(View v, AbsEntity entity) {
Aria.download(this).loadGroup(mTaskId).resume();
Aria.download(this).loadGroup(mTaskId)
.unknownSize()
.resume(true);
}
@Override public void cancel(View v, AbsEntity entity) {

@ -36,11 +36,11 @@ public class GroupModule extends BaseModule {
//urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924272&di=7861479e7cb3cea98d585eaf108f056f&imgtype=0&src=http%3A%2F%2Fd.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F562c11dfa9ec8a13c0741f5afd03918fa0ecc01a.jpg");
//String[] str = getContext().getResources().getStringArray(R.array.group_urls_1);
//Collections.addAll(urls, str);
urls.add("http://img2.imgtn.bdimg.com/it/u=3105600238,693167464&fm=26&gp=0.jpg");
urls.add("http://a4.att.hudong.com/22/59/19300001325156131228593878903.jpg");
urls.add("http://pic1.win4000.com/mobile/2019-12-16/5df71dc866a0c.jpg");
urls.add("http://pics4.baidu.com/feed/e824b899a9014c08545e5585620d360e7bf4f421.jpeg");
urls.add("http://img.blog.163.com/photo/iFUKcs6shB4PNlfxwH-yTw==/2542563464627686395.jpg");
urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-9/fr/cp0/e15/q65/85148967_168821394550033_6164348723502514176_n.jpg?_nc_cat=105&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQni9wIDOcxkQGfqH7jFwLuRWV3cIi0We11MXp1V0_vfrQ3-SBV4Ue034aJXzzIzdNI&_nc_ht=scontent-hkt1-1.xx&_nc_tp=14&oh=37829bbfd4f7179fcc3527a7a7971f53&oe=5F00FC35");
urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/84206444_168821471216692_7979166053252988928_n.jpg?_nc_cat=106&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQny1ZTkxw-sq4mSH2TThaQNRJB89uKG2cW9e3DgcI78qXE7b8Jlyox749lXkcngYBs&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=6714e2c9b3d76e12eff960b6aa22cdfb&oe=5EEE640F");
urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/86702402_168821534550019_6064732312896012288_n.jpg?_nc_cat=101&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQnfJfW55cqVfs0lzZOjEa8kGoxvrA--\\brjaelZgcf8MzqQUhjH3moqGoekMQlATXRM&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=96f4f776c05b2c200cfb720fa36f938b&oe=5EFA310D");
urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-0/cp0/e15/q65/p480x480/85236032_168821577883348_2800973234302877696_n.jpg?_nc_cat=106&_nc_sid=110474&efg=eyJpIjoidCJ9&_nc_oc=AQlNvaTlYUspquMWBLnkgVOHdzG4pX2XW3NSHYxvVYsaJF8Ehy9tGn6R6Ned5UwcwAM&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=6fd5e6442712e4da111d09e8902c68c5&oe=5EFE1528");
urls.add("https://scontent-hkt1-1.xx.fbcdn.net/v/t1.0-1/cp0/e15/q65/p120x120/80398195_141232180642288_3692820603451998208_n.jpg?_nc_cat=109&_nc_sid=dbb9e7&efg=eyJpIjoidCJ9&_nc_oc=AQmsZxgvLgoObkqHbcKS8qIZ3w_QhssRwLSF5o-8P6q_kf962w32kmjLqcg6lH9qxWI&_nc_ht=scontent-hkt1-1.xx&_nc_tp=3&oh=269e655e7b901e8d07d9362142a0fdda&oe=5EF43734");
return urls;
}

@ -39,7 +39,8 @@ public class M3U8VodModule extends BaseViewModule {
//private final String defUrl = "https://youku.cdn7-okzy.com/20191213/16167_c3592a02/index.m3u8";
//private final String defUrl = "http://qn.shytong.cn/b83137769ff6b555/11b0c9970f9a3fa0.mp4.m3u8";
//private final String defUrl = "https://135zyv5.xw0371.com/2018/10/29/X05c7CG3VB91gi1M/playlist.m3u8";
private final String defUrl = "https://fangao.qfxmj.com/video/20191111/dbf7e2aa0c5f42a8b040442b54c13e3a/cloudv-transfer/555555556nr593o75556r165q86n82n0_eb3da35b8f4442808756a6ddc8ec1372_0_3.m3u8?wsSecret=d5fb403512d4cd427f18858086b35ce4&wsTime=1582197537";
//private final String defUrl = "https://fangao.qfxmj.com/video/20191111/dbf7e2aa0c5f42a8b040442b54c13e3a/cloudv-transfer/555555556nr593o75556r165q86n82n0_eb3da35b8f4442808756a6ddc8ec1372_0_3.m3u8?wsSecret=d5fb403512d4cd427f18858086b35ce4&wsTime=1582197537";
private final String defUrl = "https://v1.szjal.cn/20190819/Ql6UD1od/index.m3u8";
private final String filePath =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
//+ "/道士下山.ts";

@ -45,7 +45,7 @@ task clean(type: Delete) {
ext {
versionCode = 387
versionName = '3.8.7-beta-1'
versionName = '3.8.7-beta-4'
userOrg = 'arialyy'
groupId = 'com.arialyy.aria'
publishVersion = versionName

Loading…
Cancel
Save