From 0c3e16cad7746ad7947a8668e97d73f2ee743952 Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Wed, 8 May 2019 19:36:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E5=90=88=E4=BB=BB=E5=8A=A1=E6=96=B0?= =?UTF-8?q?=E5=A2=9E`unknownSize()`=EF=BC=8C=E7=94=A8=E4=BA=8E=E5=A4=84?= =?UTF-8?q?=E7=90=86=E7=BB=84=E5=90=88=E4=BB=BB=E5=8A=A1=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E6=9C=AA=E7=9F=A5=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=8Chttps://g?= =?UTF-8?q?ithub.com/AriaLyy/Aria/issues/380?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aria/core/common/AbsThreadTask.java | 32 +- .../aria/core/common/CompleteInfo.java | 7 +- .../aria/core/common/StateConstance.java | 8 +- .../aria/core/common/SubThreadConfig.java | 15 + .../aria/core/download/DGTaskWrapper.java | 10 + .../core/download/DownloadGroupTarget.java | 379 +++++++++--------- .../aria/core/download/HttpGroupDelegate.java | 4 +- .../downloader/FtpFileInfoThread.java | 2 +- .../downloader/HttpFileInfoThread.java | 2 +- .../download/downloader/HttpThreadTask.java | 2 - .../downloader/SimpleDownloadUtil.java | 1 + .../core/download/group/AbsGroupUtil.java | 10 +- .../download/group/DownloadGroupUtil.java | 73 +++- .../core/download/group/FtpDirInfoThread.java | 2 +- .../download/group/SubDownloadLoader.java | 7 +- .../upload/uploader/FtpFileInfoThread.java | 3 +- .../com/arialyy/aria/util/DbDataHelper.java | 2 +- DEV_LOG.md | 1 + .../core/download/SingleTaskActivity.java | 8 +- .../download/group/DownloadGroupActivity.java | 8 +- build.gradle | 2 +- 21 files changed, 350 insertions(+), 228 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java index b1f48642..87127e4b 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java @@ -115,8 +115,7 @@ public abstract class AbsThreadTask subTaskEntities; + private boolean unknownSize = false; + public DGTaskWrapper(DownloadGroupEntity entity) { super(entity); } @@ -36,6 +38,14 @@ public class DGTaskWrapper extends AbsGroupTaskWrapper implements - IHttpHeaderDelegate { - private HttpHeaderDelegate mHeaderDelegate; - private HttpGroupDelegate mGroupDelegate; - - DownloadGroupTarget(DownloadGroupEntity groupEntity, String targetName) { - setTargetName(targetName); - if (groupEntity.getUrls() != null && !groupEntity.getUrls().isEmpty()) { - init(groupEntity.getUrls()); - } else { - throw new ParamException("组合任务只任务下载地址为空"); - } - } - - DownloadGroupTarget(List urls, String targetName) { - setTargetName(targetName); - init(urls); - } - - private void init(List urls) { - mGroupDelegate = new HttpGroupDelegate(this, - TaskWrapperManager.getInstance().getDGTaskWrapper(DGTaskWrapper.class, urls)); - mHeaderDelegate = new HttpHeaderDelegate<>(this); - } - - /** - * Post处理 - */ - @CheckResult - public PostDelegate asPost() { - return new PostDelegate<>(this); - } - - /** - * 更新组合任务下载地址 - * - * @param urls 新的组合任务下载地址列表 - */ - @CheckResult - public DownloadGroupTarget updateUrls(List urls) { - return mGroupDelegate.updateUrls(urls); - } - - /** - * 任务组总任务大小,任务组是一个抽象的概念,没有真实的数据实体,任务组的大小是Aria动态获取子任务大小相加而得到的, - * 如果你知道当前任务组总大小,你也可以调用该方法给任务组设置大小 - * - * 为了更好的用户体验,组合任务必须设置文件大小 - * - * @param fileSize 任务组总大小 - */ - @CheckResult - public DownloadGroupTarget setFileSize(long fileSize) { - if (fileSize <= 0) { - ALog.e(TAG, "文件大小不能小于 0"); - return this; - } - if (getEntity().getFileSize() <= 1 || getEntity().getFileSize() != fileSize) { - getEntity().setFileSize(fileSize); - } - return this; - } - - /** - * 如果你是使用{@link DownloadReceiver#load(DownloadGroupEntity)}进行下载操作,那么你需要设置任务组的下载地址 - */ - @CheckResult - public DownloadGroupTarget setGroupUrl(List urls) { - return mGroupDelegate.setGroupUrl(urls); - } - - /** - * 设置子任务文件名,该方法必须在{@link #setDirPath(String)}之后调用,否则不生效 - * - * @deprecated {@link #setSubFileName(List)} 请使用该api - */ - @CheckResult - @Deprecated public DownloadGroupTarget setSubTaskFileName(List subTaskFileName) { - return setSubFileName(subTaskFileName); - } - - /** - * 设置任务组的文件夹路径,在Aria中,任务组的所有子任务都会下载到以任务组组名的文件夹中。 - * 如:groupDirPath = "/mnt/sdcard/download/group_test" - *
-   *   {@code
-   *      + mnt
-   *        + sdcard
-   *          + download
-   *            + group_test
-   *              - task1.apk
-   *              - task2.apk
-   *              - task3.apk
-   *              ....
-   *
-   *   }
-   * 
- * - * @param dirPath 任务组保存文件夹路径 - */ - @CheckResult - public DownloadGroupTarget setDirPath(String dirPath) { - return mGroupDelegate.setDirPath(dirPath); - } - - /** - * 设置子任务文件名,该方法必须在{@link #setDirPath(String)}之后调用,否则不生效 - */ - @CheckResult - public DownloadGroupTarget setSubFileName(List subTaskFileName) { - return mGroupDelegate.setSubFileName(subTaskFileName); - } - - @Override public int getTargetType() { - return GROUP_HTTP; - } - - @Override protected boolean checkEntity() { - return mGroupDelegate.checkEntity(); - } - - @Override public boolean isRunning() { - return mGroupDelegate.isRunning(); - } - - @Override public boolean taskExists() { - return mGroupDelegate.taskExists(); - } - - @CheckResult - @Override public DownloadGroupTarget addHeader(@NonNull String key, @NonNull String value) { - for (DTaskWrapper subTask : getTaskWrapper().getSubTaskWrapper()) { - mHeaderDelegate.addHeader(subTask, key, value); - } - return mHeaderDelegate.addHeader(key, value); - } - - @CheckResult - @Override public DownloadGroupTarget addHeaders(Map headers) { - for (DTaskWrapper subTask : getTaskWrapper().getSubTaskWrapper()) { - mHeaderDelegate.addHeaders(subTask, headers); - } - return mHeaderDelegate.addHeaders(headers); - } - - @CheckResult - @Override public DownloadGroupTarget setUrlProxy(Proxy proxy) { - return mHeaderDelegate.setUrlProxy(proxy); - } -} +/* + * Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.arialyy.aria.core.download; + +import android.support.annotation.CheckResult; +import android.support.annotation.NonNull; +import com.arialyy.aria.core.common.http.HttpHeaderDelegate; +import com.arialyy.aria.core.common.http.PostDelegate; +import com.arialyy.aria.core.inf.IHttpHeaderDelegate; +import com.arialyy.aria.core.manager.TaskWrapperManager; +import com.arialyy.aria.exception.ParamException; +import com.arialyy.aria.util.ALog; +import java.net.Proxy; +import java.util.List; +import java.util.Map; + +/** + * Created by AriaL on 2017/6/29. + * 下载任务组 + */ +public class DownloadGroupTarget extends AbsDGTarget implements + IHttpHeaderDelegate { + private HttpHeaderDelegate mHeaderDelegate; + private HttpGroupDelegate mGroupDelegate; + + DownloadGroupTarget(DownloadGroupEntity groupEntity, String targetName) { + setTargetName(targetName); + if (groupEntity.getUrls() != null && !groupEntity.getUrls().isEmpty()) { + init(groupEntity.getUrls()); + } else { + throw new ParamException("组合任务只任务下载地址为空"); + } + } + + DownloadGroupTarget(List urls, String targetName) { + setTargetName(targetName); + init(urls); + } + + private void init(List urls) { + mGroupDelegate = new HttpGroupDelegate(this, + TaskWrapperManager.getInstance().getDGTaskWrapper(DGTaskWrapper.class, urls)); + mHeaderDelegate = new HttpHeaderDelegate<>(this); + } + + /** + * Post处理 + */ + @CheckResult + public PostDelegate asPost() { + return new PostDelegate<>(this); + } + + /** + * 更新组合任务下载地址 + * + * @param urls 新的组合任务下载地址列表 + */ + @CheckResult + public DownloadGroupTarget updateUrls(List urls) { + return mGroupDelegate.updateUrls(urls); + } + + /** + * 任务组总任务大小,任务组是一个抽象的概念,没有真实的数据实体,任务组的大小是Aria动态获取子任务大小相加而得到的, + * 如果你知道当前任务组总大小,你也可以调用该方法给任务组设置大小 + * + * 为了更好的用户体验,组合任务最好设置文件大小,默认需要强制设置文件大小。如果无法获取到总长度,请调用{@link #unknownSize()} + * + * @param fileSize 任务组总大小 + */ + @CheckResult + public DownloadGroupTarget setFileSize(long fileSize) { + if (fileSize <= 0) { + ALog.e(TAG, "文件大小不能小于 0"); + return this; + } + if (getEntity().getFileSize() <= 1 || getEntity().getFileSize() != fileSize) { + getEntity().setFileSize(fileSize); + } + return this; + } + + /** + * 如果无法获取到组合任务到总长度,请调用该方法, + * 请注意: + * 1、如果组合任务到子任务数过多,请不要使用该标志位,否则Aria将需要消耗大量的时间获取组合任务的总长度。 + * 2、如果你的知道组合任务的总长度,请使用{@link #setFileSize(long)}设置组合任务的长度。 + * 3、由于网络或其它原因的存在,这种方式获取的组合任务大小有可能是不准确的。 + */ + @CheckResult + public DownloadGroupTarget unknownSize() { + getTaskWrapper().setUnknownSize(true); + return this; + } + + /** + * 如果你是使用{@link DownloadReceiver#load(DownloadGroupEntity)}进行下载操作,那么你需要设置任务组的下载地址 + */ + @CheckResult + public DownloadGroupTarget setGroupUrl(List urls) { + return mGroupDelegate.setGroupUrl(urls); + } + + /** + * 设置子任务文件名,该方法必须在{@link #setDirPath(String)}之后调用,否则不生效 + * + * @deprecated {@link #setSubFileName(List)} 请使用该api + */ + @CheckResult + @Deprecated public DownloadGroupTarget setSubTaskFileName(List subTaskFileName) { + return setSubFileName(subTaskFileName); + } + + /** + * 设置任务组的文件夹路径,在Aria中,任务组的所有子任务都会下载到以任务组组名的文件夹中。 + * 如:groupDirPath = "/mnt/sdcard/download/group_test" + *
+   *   {@code
+   *      + mnt
+   *        + sdcard
+   *          + download
+   *            + group_test
+   *              - task1.apk
+   *              - task2.apk
+   *              - task3.apk
+   *              ....
+   *
+   *   }
+   * 
+ * + * @param dirPath 任务组保存文件夹路径 + */ + @CheckResult + public DownloadGroupTarget setDirPath(String dirPath) { + return mGroupDelegate.setDirPath(dirPath); + } + + /** + * 设置子任务文件名,该方法必须在{@link #setDirPath(String)}之后调用,否则不生效 + */ + @CheckResult + public DownloadGroupTarget setSubFileName(List subTaskFileName) { + return mGroupDelegate.setSubFileName(subTaskFileName); + } + + @Override public int getTargetType() { + return GROUP_HTTP; + } + + @Override protected boolean checkEntity() { + return mGroupDelegate.checkEntity(); + } + + @Override public boolean isRunning() { + return mGroupDelegate.isRunning(); + } + + @Override public boolean taskExists() { + return mGroupDelegate.taskExists(); + } + + @CheckResult + @Override public DownloadGroupTarget addHeader(@NonNull String key, @NonNull String value) { + for (DTaskWrapper subTask : getTaskWrapper().getSubTaskWrapper()) { + mHeaderDelegate.addHeader(subTask, key, value); + } + return mHeaderDelegate.addHeader(key, value); + } + + @CheckResult + @Override public DownloadGroupTarget addHeaders(Map headers) { + for (DTaskWrapper subTask : getTaskWrapper().getSubTaskWrapper()) { + mHeaderDelegate.addHeaders(subTask, headers); + } + return mHeaderDelegate.addHeaders(headers); + } + + @CheckResult + @Override public DownloadGroupTarget setUrlProxy(Proxy proxy) { + return mHeaderDelegate.setUrlProxy(proxy); + } +} diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/HttpGroupDelegate.java b/Aria/src/main/java/com/arialyy/aria/core/download/HttpGroupDelegate.java index 2175c311..3f3436d8 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/HttpGroupDelegate.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/HttpGroupDelegate.java @@ -114,8 +114,8 @@ class HttpGroupDelegate extends AbsGroupDelegate { return false; } - if (getTaskWrapper().getEntity().getFileSize() == 0) { - ALog.e(TAG, "组合任务必须设置文件文件大小"); + if (!getTaskWrapper().isUnknownSize() && getTaskWrapper().getEntity().getFileSize() == 0) { + ALog.e(TAG, "组合任务必须设置文件文件大小,默认需要强制设置文件大小。如果无法获取到总长度,请调用#unknownSize()来标志该组合任务"); return false; } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpFileInfoThread.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpFileInfoThread.java index 205d9109..31fcf744 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpFileInfoThread.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpFileInfoThread.java @@ -55,6 +55,6 @@ class FtpFileInfoThread extends AbsFtpInfoThread { mTaskWrapper.setNewTask(true); } mEntity.setFileSize(mSize); - mCallback.onComplete(mEntity.getUrl(), new CompleteInfo(code)); + mCallback.onComplete(mEntity.getUrl(), new CompleteInfo(code, mTaskWrapper)); } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java index 18e19f16..4e8c14d9 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java @@ -220,7 +220,7 @@ public class HttpFileInfoThread implements Runnable { if (end) { mTaskDelegate.setChunked(isChunked); if (onFileInfoCallback != null) { - CompleteInfo info = new CompleteInfo(code); + CompleteInfo info = new CompleteInfo(code, mTaskWrapper); onFileInfoCallback.onComplete(mEntity.getUrl(), info); } mEntity.update(); diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java index 130255f0..2b482674 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java @@ -29,7 +29,6 @@ import com.arialyy.aria.exception.TaskException; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.BufferedRandomAccessFile; import java.io.BufferedInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -44,7 +43,6 @@ import java.nio.channels.FileChannel; import java.nio.channels.ReadableByteChannel; import java.util.Map; import java.util.Set; -import java.util.zip.GZIPInputStream; /** * Created by lyy on 2017/1/18. 下载线程 diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/SimpleDownloadUtil.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/SimpleDownloadUtil.java index e35a3801..fd77ab50 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/SimpleDownloadUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/SimpleDownloadUtil.java @@ -107,6 +107,7 @@ public class SimpleDownloadUtil implements IUtil, Runnable { if (isStop || isCancel) { return; } + // 如果网址没有变,而服务器端端文件改变,以下代码就没有用了 //if (mTaskWrapper.getEntity().getFileSize() <= 1 // || mTaskWrapper.isRefreshInfo() // || mTaskWrapper.getRequestType() == AbsTaskWrapper.D_FTP diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/group/AbsGroupUtil.java b/Aria/src/main/java/com/arialyy/aria/core/download/group/AbsGroupUtil.java index 725b3668..a5671f99 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/group/AbsGroupUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/group/AbsGroupUtil.java @@ -288,7 +288,15 @@ public abstract class AbsGroupUtil implements IUtil, Runnable { * 创建并启动子任务下载器 */ SubDownloadLoader createSubLoader(DTaskWrapper taskWrapper) { - SubDownloadLoader loader = new SubDownloadLoader(mScheduler, taskWrapper); + return createSubLoader(taskWrapper, true); + } + + /** + * 创建并启动子任务下载器 + * @param needGetFileInfo {@code true} 需要获取文件信息。{@code false} 不需要获取文件信息 + */ + SubDownloadLoader createSubLoader(DTaskWrapper taskWrapper, boolean needGetFileInfo) { + SubDownloadLoader loader = new SubDownloadLoader(mScheduler, taskWrapper, needGetFileInfo); mExeLoader.put(loader.getKey(), loader); mSubQueue.startTask(loader); return loader; diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/group/DownloadGroupUtil.java b/Aria/src/main/java/com/arialyy/aria/core/download/group/DownloadGroupUtil.java index 09a48055..d9440d2e 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/group/DownloadGroupUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/group/DownloadGroupUtil.java @@ -15,16 +15,26 @@ */ package com.arialyy.aria.core.download.group; +import com.arialyy.aria.core.common.CompleteInfo; import com.arialyy.aria.core.common.IUtil; +import com.arialyy.aria.core.common.OnFileInfoCallback; import com.arialyy.aria.core.download.DGTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper; +import com.arialyy.aria.core.download.downloader.HttpFileInfoThread; import com.arialyy.aria.core.inf.IEntity; +import com.arialyy.aria.exception.BaseException; +import com.arialyy.aria.util.ALog; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * Created by AriaL on 2017/6/30. * 任务组下载工具 */ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil { + private static final String TAG = "DownloadGroupUtil"; + private final Object LOCK = new Object(); + private ExecutorService mPool = null; public DownloadGroupUtil(IDownloadGroupListener listener, DGTaskWrapper taskWrapper) { super(listener, taskWrapper); @@ -47,11 +57,68 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil { if (mState.getCompleteNum() == mState.getSubSize()) { mListener.onComplete(); } else { - for (DTaskWrapper wrapper : mGTWrapper.getSubTaskWrapper()) { - if (wrapper.getState() != IEntity.STATE_COMPLETE) { - createSubLoader(wrapper); + // 处理组合任务大小未知的情况 + if (mGTWrapper.isUnknownSize() && mGTWrapper.getEntity().getFileSize() < 1) { + mPool = Executors.newCachedThreadPool(); + getGroupSize(); + try { + synchronized (LOCK) { + LOCK.wait(); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + } else { + for (DTaskWrapper wrapper : mGTWrapper.getSubTaskWrapper()) { + if (wrapper.getState() != IEntity.STATE_COMPLETE) { + createSubLoader(wrapper); + } } } } } + + /** + * 获取组合任务大小,使用该方式获取到的组合任务大小,子任务不需要再重新获取文件大小 + */ + private void getGroupSize() { + new Thread(new Runnable() { + int count; + + @Override public void run() { + for (DTaskWrapper dTaskWrapper : mGTWrapper.getSubTaskWrapper()) { + mPool.submit(new HttpFileInfoThread(dTaskWrapper, new OnFileInfoCallback() { + @Override public void onComplete(String url, CompleteInfo info) { + createSubLoader((DTaskWrapper) info.wrapper, false); + count++; + checkGetSizeComplete(count); + } + + @Override public void onFail(String url, BaseException e, boolean needRetry) { + ALog.e(TAG, String.format("获取文件信息失败,url:%s", url)); + count++; + checkGetSizeComplete(count); + } + })); + } + } + }).start(); + } + + /** + * 检查组合任务大小是否获取完成,获取完成后取消阻塞,并设置组合任务大小 + */ + private void checkGetSizeComplete(int count) { + if (count == mGTWrapper.getSubTaskWrapper().size()) { + long size = 0; + for (DTaskWrapper wrapper : mGTWrapper.getSubTaskWrapper()) { + size += wrapper.getEntity().getFileSize(); + } + mGTWrapper.getEntity().setFileSize(size); + + synchronized (LOCK) { + LOCK.notify(); + } + } + } } \ No newline at end of file diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirInfoThread.java b/Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirInfoThread.java index 7f8be3c1..69915616 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirInfoThread.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirInfoThread.java @@ -50,7 +50,7 @@ class FtpDirInfoThread extends AbsFtpInfoThread { @Override protected void onPreComplete(int code) { super.onPreComplete(code); - mCallback.onComplete(mEntity.getKey(), new CompleteInfo(isComplete ? CODE_COMPLETE : code)); + mCallback.onComplete(mEntity.getKey(), + new CompleteInfo(isComplete ? CODE_COMPLETE : code, mTaskWrapper)); } } diff --git a/Aria/src/main/java/com/arialyy/aria/util/DbDataHelper.java b/Aria/src/main/java/com/arialyy/aria/util/DbDataHelper.java index cd5825f9..78da9ae2 100644 --- a/Aria/src/main/java/com/arialyy/aria/util/DbDataHelper.java +++ b/Aria/src/main/java/com/arialyy/aria/util/DbDataHelper.java @@ -56,7 +56,7 @@ public class DbDataHelper { DbEntity.findRelationData(DGEntityWrapper.class, "DownloadGroupEntity.groupHash=?", groupHash); - return wrapper == null ? null : wrapper.get(0).groupEntity; + return wrapper == null || wrapper.size() == 0 ? null : wrapper.get(0).groupEntity; } /** diff --git a/DEV_LOG.md b/DEV_LOG.md index f387c733..15653872 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -10,6 +10,7 @@ - fix bug https://github.com/AriaLyy/Aria/issues/388 - 修复使用`Content-Disposition`的文件名时,第一次下载无法重命名文件的问题 - 修复使用`Content-Disposition`的文件名时,多次重命名文件的问题 + - 组合任务新增`unknownSize()`,用于处理组合任务大小未知的情况,https://github.com/AriaLyy/Aria/issues/380 + v_3.6.3 (2019/4/2) - fix bug https://github.com/AriaLyy/Aria/issues/377 + v_3.6.2 (2019/4/1) diff --git a/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java index 3d280298..ed4a407a 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java @@ -59,9 +59,9 @@ public class SingleTaskActivity extends BaseActivity { //"http://120.55.95.61:8811/ghcg/zg/武义总规纲要成果.zip"; //"https://yizi-kejian.oss-cn-beijing.aliyuncs.com/qimeng/package1/qmtable11.zip"; //"http://rs.0.gaoshouyou.com/d/04/1e/400423a7551e1f3f0eb1812afa1f9b44.apk"; - //"http://chargepile2.techsum.net/car-manage/file/download?path=2019-04-26/c0242efd18be4ecbb23911b1c509dcad--掌通各系统汇总.xls"; // 无长度的chunked + "http://chargepile2.techsum.net/car-manage/file/download?path=2019-04-26/c0242efd18be4ecbb23911b1c509dcad--掌通各系统汇总.xls"; // 无长度的chunked //"http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载 - "http://apk500.bce.baidu-mgame.com/game/67000/67734/20170622040827_oem_5502845.apk?r=1"; + //"http://apk500.bce.baidu-mgame.com/game/67000/67734/20170622040827_oem_5502845.apk?r=1"; //"https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe"; //"http://9.9.9.50:5000/download/CentOS-7-x86_64-Minimal-1804.iso"; //"http://v2.qingdian1.com/m_20180730_991/2/2B9FB34A4BCD8CE61481D1C8418EFE36_1080P.m3u8"; @@ -316,8 +316,8 @@ public class SingleTaskActivity extends BaseActivity { Aria.download(SingleTaskActivity.this) .load(DOWNLOAD_URL) //.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3") - .addHeader("Accept-Encoding", "gzip, deflate") - .addHeader("DNT", "1") + //.addHeader("Accept-Encoding", "gzip, deflate") + //.addHeader("DNT", "1") //.addHeader("Cookie", "BAIDUID=648E5FF020CC69E8DD6F492D1068AAA9:FG=1; BIDUPSID=648E5FF020CC69E8DD6F492D1068AAA9; PSTM=1519099573; BD_UPN=12314753; locale=zh; BDSVRTM=0") .useServerFileName(true) .setFilePath(path, true) diff --git a/app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java b/app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java index 22680684..8ff0b7da 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java @@ -24,14 +24,12 @@ import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadGroupEntity; import com.arialyy.aria.core.download.DownloadGroupTask; -import com.arialyy.aria.core.download.DGTaskWrapper; import com.arialyy.frame.util.show.L; import com.arialyy.frame.util.show.T; import com.arialyy.simple.R; import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.databinding.ActivityDownloadGroupBinding; import com.arialyy.simple.widget.SubStateLinearLayout; -import java.util.ArrayList; import java.util.List; /** @@ -80,9 +78,6 @@ public class DownloadGroupActivity extends BaseActivity temp = new ArrayList<>(); - temp.add( - "https://d.pcs.baidu.com/file/130335545f3f4d9cc38afe709c19af5a?fid=1411168371-250528-1010657263806840&dstime=1531134714&rt=sh&sign=FDtAERVY-DCb740ccc5511e5e8fedcff06b081203-h8KgJ6gl4oY9UR6NqvwJsT4nVSM%3D&expires=8h&chkv=1&chkbd=0&chkpc=et&dp-logid=4401996296756616039&dp-callid=0&r=279987343"); Aria.download(this) .loadGroup(mUrls) .setDirPath( @@ -91,7 +86,8 @@ public class DownloadGroupActivity extends BaseActivity