Skip to content
Permalink
Browse files

fix bug #379 #388

移除`getDownloadTask(String url)`、`getGroupTask(List<String>urls)`、`getFtpDirTask(String path)`等获取任务的api
修复使用`Content-Disposition`的文件名时,第一次下载无法重命名文件的问题
修复使用`Content-Disposition`的文件名时,多次重命名文件的问题
  • Loading branch information...
AriaLyy committed Apr 29, 2019
1 parent 0a44778 commit 8c0ef0f87959f55a2fcd0296595f9177b5896a6e
Showing with 2,592 additions and 2,422 deletions.
  1. +10 −1 Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java
  2. +1 −1 Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java
  3. +4 −0 Aria/src/main/java/com/arialyy/aria/core/download/DNormalDelegate.java
  4. +457 −474 Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java
  5. +101 −0 Aria/src/main/java/com/arialyy/aria/core/download/downloader/ChunkedInputStream.java
  6. +21 −21 Aria/src/main/java/com/arialyy/aria/core/download/downloader/ConnectionHelp.java
  7. +15 −0 Aria/src/main/java/com/arialyy/aria/core/download/downloader/Downloader.java
  8. +41 −17 Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java
  9. +52 −17 Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java
  10. +2 −0 Aria/src/main/java/com/arialyy/aria/core/download/downloader/SimpleDownloadUtil.java
  11. +2 −2 Aria/src/main/java/com/arialyy/aria/core/manager/DGTaskWrapperFactory.java
  12. +18 −15 Aria/src/main/java/com/arialyy/aria/core/manager/DTaskWrapperFactory.java
  13. +0 −2 Aria/src/main/java/com/arialyy/aria/core/upload/UploadReceiver.java
  14. +1 −60 Aria/src/main/java/com/arialyy/aria/orm/AbsDelegate.java
  15. +1 −0 Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java
  16. +0 −8 Aria/src/main/java/com/arialyy/aria/orm/DelegateCommon.java
  17. +631 −640 Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java
  18. +0 −4 Aria/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java
  19. +1 −1 Aria/src/main/java/com/arialyy/aria/orm/DelegateWrapper.java
  20. +301 −256 Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
  21. +268 −253 Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
  22. +16 −2 Aria/src/main/java/com/arialyy/aria/util/DbDataHelper.java
  23. +225 −218 DEV_LOG.md
  24. +172 −172 README.md
  25. +160 −160 app/src/main/assets/aria_config.xml
  26. +17 −20 app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java
  27. +9 −9 app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java
  28. +8 −9 app/src/main/java/com/arialyy/simple/core/download/group/FTPDirDownloadActivity.java
  29. +0 −2 app/src/main/java/com/arialyy/simple/core/test/AnyRunActivity.java
  30. +58 −58 build.gradle
@@ -141,10 +141,11 @@ private void startFlow() {
}
resetState();
mConstance.resetState();
ALog.d(TAG, "path: " + getFilePath());
checkRecord();
mConstance.isRunning = true;
mConstance.TASK_RECORD = mRecord;
if (!mTaskWrapper.isSupportBP()) {
if (!mTaskWrapper.isSupportBP() || mTaskWrapper.asHttp().isChunked()) {
mTotalThreadNum = 1;
} else {
mTotalThreadNum =
@@ -348,6 +349,7 @@ private void handleNormalRecord() {
if (mRecord.isOpenDynamicFile) {
ThreadRecord tr = mRecord.threadRecords.get(0);
if (tr == null) {
ALog.d(TAG, "线程记录为空,任务为新任务");
mTaskWrapper.setNewTask(true);
mTotalThreadNum = 1;
return;
@@ -438,6 +440,7 @@ private void convertDb() {
if (records == null || records.size() == 0) {
Properties pro = CommonUtil.loadConfig(mConfigFile);
if (pro.isEmpty()) {
ALog.d(TAG, "老版本的线程记录为空,任务为新任务");
mTaskWrapper.setNewTask(true);
return;
}
@@ -453,6 +456,7 @@ private void convertDb() {
}
int threadNum = set.size();
if (threadNum == 0) {
ALog.d(TAG, "线程数为空,任务为新任务");
mTaskWrapper.setNewTask(true);
return;
}
@@ -495,6 +499,7 @@ private void initRecord(boolean isNewTask) {
mRecord.dGroupHash = ((DownloadEntity) mTaskWrapper.getEntity()).getGroupHash();
}
}
ALog.d(TAG, String.format("初始化记录,任务为%s任务", isNewTask ? "" : ""));
mTaskWrapper.setNewTask(isNewTask);
}

@@ -569,6 +574,10 @@ private void handleBreakpoint() {
long fileLength = mEntity.getFileSize();
long blockSize = fileLength / mTotalThreadNum;
Set<Integer> threads = new HashSet<>();
// 如果是新任务,检查下历史记录,如果有遗留的记录,删除并删除分块文件
if (mTaskWrapper.isNewTask()) {
CommonUtil.delTaskRecord(getFilePath(), 1, true);
}

mRecord.fileLength = fileLength;
if (mTaskWrapper.isNewTask() && !handleNewTask()) {
@@ -316,7 +316,7 @@ public void stop() {
*/
protected void progress(long len) {
synchronized (AriaManager.LOCK) {
if (STATE.CURRENT_LOCATION > mEntity.getFileSize()) {
if (STATE.CURRENT_LOCATION > mEntity.getFileSize() && !mTaskWrapper.asHttp().isChunked()) {
String errorMsg =
String.format("下载失败,下载长度超出文件真实长度;currentLocation=%s, fileSize=%s",
STATE.CURRENT_LOCATION,
@@ -145,6 +145,10 @@ TARGET updateUrl(String newUrl) {
File newFile = new File(filePath);
mEntity.setDownloadPath(filePath);
mEntity.setFileName(newFile.getName());
// 如过使用Content-Disposition中的文件名,将不会执行重命名工作
if (mTarget.getTaskWrapper().asHttp().isUseServerFileName()) {
return true;
}
if (oldFile.exists()) {
// 处理普通任务的重命名
CommonUtil.modifyTaskRecord(oldFile.getPath(), newFile.getPath());
Oops, something went wrong.

0 comments on commit 8c0ef0f

Please sign in to comment.
You can’t perform that action at this time.