loader 优化

This commit is contained in:
laoyuyu
2019-12-28 13:18:20 +08:00
parent c9eb57132b
commit 1e237d795d
52 changed files with 1005 additions and 691 deletions

View File

@@ -24,7 +24,8 @@ import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.common.RequestEnum;
import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.OnFileInfoCallback;
import com.arialyy.aria.core.loader.IInfoTask;
import com.arialyy.aria.core.loader.ILoaderVisitor;
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.BaseException;
@@ -54,19 +55,18 @@ import java.util.UUID;
/**
* 下载文件信息获取
*/
public class HttpFileInfoThread implements Runnable {
public class HttpFileInfoTask implements IInfoTask, Runnable {
private static final String TAG = "HttpFileInfoThread";
private DownloadEntity mEntity;
private DTaskWrapper mTaskWrapper;
private int mConnectTimeOut;
private OnFileInfoCallback onFileInfoCallback;
private Callback callback;
private HttpTaskOption taskOption;
public HttpFileInfoThread(DTaskWrapper taskWrapper, OnFileInfoCallback callback) {
public HttpFileInfoTask(DTaskWrapper taskWrapper) {
this.mTaskWrapper = taskWrapper;
mEntity = taskWrapper.getEntity();
mConnectTimeOut = AriaConfig.getInstance().getDConfig().getConnectTimeOut();
onFileInfoCallback = callback;
taskOption = (HttpTaskOption) taskWrapper.getTaskOption();
}
@@ -99,6 +99,10 @@ public class HttpFileInfoThread implements Runnable {
}
}
@Override public void setCallback(Callback callback) {
this.callback = callback;
}
private void handleConnect(HttpURLConnection conn) throws IOException {
if (taskOption.getRequestEnum() == RequestEnum.POST) {
Map<String, String> params = taskOption.getParams();
@@ -223,9 +227,9 @@ public class HttpFileInfoThread implements Runnable {
}
if (end) {
taskOption.setChunked(isChunked);
if (onFileInfoCallback != null) {
if (callback != null) {
CompleteInfo info = new CompleteInfo(code, mTaskWrapper);
onFileInfoCallback.onComplete(mEntity.getUrl(), info);
callback.onSucceed(mEntity.getUrl(), info);
}
mEntity.update();
}
@@ -291,8 +295,8 @@ public class HttpFileInfoThread implements Runnable {
private void handleUrlReTurn(HttpURLConnection conn, String newUrl) throws IOException {
ALog.d(TAG, "30x跳转新url为【" + newUrl + "");
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
if (onFileInfoCallback != null) {
onFileInfoCallback.onFail(mEntity, new TaskException(TAG, "获取重定向链接失败"), false);
if (callback != null) {
callback.onFail(mEntity, new TaskException(TAG, "获取重定向链接失败"), false);
}
return;
}
@@ -336,11 +340,15 @@ public class HttpFileInfoThread implements Runnable {
}
private void failDownload(BaseException e, boolean needRetry) {
if (onFileInfoCallback != null) {
onFileInfoCallback.onFail(mEntity, e, needRetry);
if (callback != null) {
callback.onFail(mEntity, e, needRetry);
}
}
@Override public void accept(ILoaderVisitor visitor) {
visitor.addComponent(this);
}
private static class FileLenAdapter implements IHttpFileLenAdapter {
@Override public long handleFileLen(Map<String, List<String>> headers) {

View File

@@ -0,0 +1,167 @@
/*
* 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.http;
import com.arialyy.aria.core.common.AbsEntity;
import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.download.DGTaskWrapper;
import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.listener.DownloadGroupListener;
import com.arialyy.aria.core.loader.IInfoTask;
import com.arialyy.aria.core.loader.ILoaderVisitor;
import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 组合任务文件信息,用于获取长度未知时,组合任务的长度
*/
public class HttpGroupInfoTask implements IInfoTask {
private String TAG = CommonUtil.getClassName(this);
private Callback callback;
private DGTaskWrapper wrapper;
private final Object LOCK = new Object();
private ExecutorService mPool = null;
private boolean getLenComplete = false;
private int count;
private int failCount;
private DownloadGroupListener listener;
/**
* 子任务回调
*/
private Callback subCallback = new Callback() {
@Override public void onSucceed(String url, CompleteInfo info) {
count++;
checkGetSizeComplete(count, failCount);
ALog.d(TAG, "获取子任务信息完成");
}
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
ALog.e(TAG, String.format("获取文件信息失败url%s", ((DownloadEntity) entity).getUrl()));
count++;
failCount++;
listener.onSubFail((DownloadEntity) entity, new AriaIOException(TAG,
String.format("子任务获取文件长度失败url%s", ((DownloadEntity) entity).getUrl())));
checkGetSizeComplete(count, failCount);
}
};
public HttpGroupInfoTask(DGTaskWrapper wrapper, DownloadGroupListener listener) {
this.wrapper = wrapper;
this.listener = listener;
}
@Override public void run() {
// 如果是isUnknownSize()标志并且获取大小没有完成则直接回调onStop
if (mPool != null && !getLenComplete) {
ALog.d(TAG, "获取长度未完成的情况下,停止组合任务");
mPool.shutdown();
//mListener.onStop(0);
return;
}
// 处理组合任务大小未知的情况
if (wrapper.isUnknownSize() && wrapper.getEntity().getFileSize() < 1) {
mPool = Executors.newCachedThreadPool();
getGroupSize();
try {
synchronized (LOCK) {
LOCK.wait();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
for (DTaskWrapper wrapper : wrapper.getSubTaskWrapper()) {
cloneHeader(wrapper);
}
callback.onSucceed(wrapper.getKey(), new CompleteInfo());
}
}
/**
* 获取组合任务大小,使用该方式获取到的组合任务大小,子任务不需要再重新获取文件大小
*/
private void getGroupSize() {
new Thread(new Runnable() {
@Override public void run() {
for (DTaskWrapper dTaskWrapper : wrapper.getSubTaskWrapper()) {
cloneHeader(dTaskWrapper);
HttpFileInfoTask infoTask = new HttpFileInfoTask(dTaskWrapper);
infoTask.setCallback(subCallback);
}
}
}).start();
}
/**
* 检查组合任务大小是否获取完成,获取完成后取消阻塞,并设置组合任务大小
*/
private void checkGetSizeComplete(int count, int failCount) {
if (failCount == wrapper.getSubTaskWrapper().size()) {
callback.onFail(wrapper.getEntity(), new AriaIOException(TAG, "获取子任务长度失败"), false);
notifyLock();
return;
}
if (count == wrapper.getSubTaskWrapper().size()) {
long size = 0;
for (DTaskWrapper wrapper : wrapper.getSubTaskWrapper()) {
size += wrapper.getEntity().getFileSize();
}
wrapper.getEntity().setConvertFileSize(CommonUtil.formatFileSize(size));
wrapper.getEntity().setFileSize(size);
wrapper.getEntity().update();
getLenComplete = true;
ALog.d(TAG, String.format("获取组合任务长度完成,组合任务总长度:%s失败的只任务数%s", size, failCount));
callback.onSucceed(wrapper.getKey(), new CompleteInfo());
notifyLock();
}
}
private void notifyLock() {
synchronized (LOCK) {
LOCK.notifyAll();
}
}
/**
* 子任务使用父包裹器的属性
*/
private void cloneHeader(DTaskWrapper taskWrapper) {
HttpTaskOption groupOption = (HttpTaskOption) wrapper.getTaskOption();
HttpTaskOption subOption = new HttpTaskOption();
// 设置属性
subOption.setFileLenAdapter(groupOption.getFileLenAdapter());
subOption.setRequestEnum(groupOption.getRequestEnum());
subOption.setHeaders(groupOption.getHeaders());
subOption.setProxy(groupOption.getProxy());
subOption.setParams(groupOption.getParams());
taskWrapper.setTaskOption(subOption);
}
@Override public void setCallback(Callback callback) {
this.callback = callback;
}
@Override public void accept(ILoaderVisitor visitor) {
visitor.addComponent(this);
}
}

View File

@@ -17,11 +17,11 @@ package com.arialyy.aria.http;
import com.arialyy.aria.core.TaskRecord;
import com.arialyy.aria.core.ThreadRecord;
import com.arialyy.aria.core.common.AbsRecordHandlerAdapter;
import com.arialyy.aria.core.common.RecordHandler;
import com.arialyy.aria.core.common.RecordHelper;
import com.arialyy.aria.core.config.Configuration;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.IRecordHandler;
import com.arialyy.aria.core.loader.IRecordHandler;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.util.RecordUtil;
@@ -31,16 +31,16 @@ import java.util.ArrayList;
* @Author lyy
* @Date 2019-09-23
*/
public class HttpRecordAdapter extends AbsRecordHandlerAdapter {
public HttpRecordAdapter(AbsTaskWrapper wrapper) {
public class HttpRecordHandler extends RecordHandler {
public HttpRecordHandler(AbsTaskWrapper wrapper) {
super(wrapper);
}
@Override public void onPre() {
super.onPre();
if (getWrapper().getRequestType() == ITaskWrapper.U_HTTP) {
RecordUtil.delTaskRecord(getEntity().getFilePath(), IRecordHandler.TYPE_UPLOAD);
}
//if (getWrapper().getRequestType() == ITaskWrapper.U_HTTP) {
// RecordUtil.delTaskRecord(getEntity().getFilePath(), IRecordHandler.TYPE_UPLOAD);
//}
}
@Override public void handlerTaskRecord(TaskRecord record) {

View File

@@ -25,9 +25,9 @@ import com.arialyy.aria.core.listener.IEventListener;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.core.group.AbsGroupUtil;
import com.arialyy.aria.core.group.AbsGroupLoaderUtil;
import com.arialyy.aria.core.group.AbsSubDLoadUtil;
import com.arialyy.aria.http.HttpFileInfoThread;
import com.arialyy.aria.http.HttpFileInfoTask;
import com.arialyy.aria.http.HttpTaskOption;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
@@ -40,7 +40,7 @@ import java.util.concurrent.Executors;
* Created by AriaL on 2017/6/30.
* 任务组下载工具
*/
public class DGroupLoaderUtil extends AbsGroupUtil {
public class DGroupLoaderUtil extends AbsGroupLoaderUtil {
private final Object LOCK = new Object();
private ExecutorService mPool = null;
private boolean getLenComplete = false;
@@ -113,7 +113,7 @@ public class DGroupLoaderUtil extends AbsGroupUtil {
@Override public void run() {
for (DTaskWrapper dTaskWrapper : getWrapper().getSubTaskWrapper()) {
cloneHeader(dTaskWrapper);
mPool.submit(new HttpFileInfoThread(dTaskWrapper, new OnFileInfoCallback() {
mPool.submit(new HttpFileInfoTask(dTaskWrapper, new OnFileInfoCallback() {
@Override public void onComplete(String url, CompleteInfo info) {
if (!getWrapper().isUnknownSize()) {
startSubLoader(createSubLoader((DTaskWrapper) info.wrapper, false));

View File

@@ -1,100 +1,100 @@
/*
* 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.http.download;
import com.arialyy.aria.core.TaskRecord;
import com.arialyy.aria.core.common.RecordHandler;
import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.IRecordHandler;
import com.arialyy.aria.core.task.AbsNormalLoaderAdapter;
import com.arialyy.aria.core.task.IThreadTask;
import com.arialyy.aria.core.task.ThreadTask;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.http.HttpRecordAdapter;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.BufferedRandomAccessFile;
import com.arialyy.aria.util.FileUtil;
import java.io.File;
import java.io.IOException;
/**
* @Author lyy
* @Date 2019-09-21
*/
final class HttpDLoaderAdapter extends AbsNormalLoaderAdapter {
HttpDLoaderAdapter(ITaskWrapper wrapper) {
super(wrapper);
}
@Override public boolean handleNewTask(TaskRecord record, int totalThreadNum) {
if (!record.isBlock) {
if (getTempFile().exists()) {
FileUtil.deleteFile(getTempFile());
}
} else {
for (int i = 0; i < totalThreadNum; i++) {
File blockFile =
new File(String.format(IRecordHandler.SUB_PATH, getTempFile().getPath(), i));
if (blockFile.exists()) {
ALog.d(TAG, String.format("分块【%s】已经存在将删除该分块", i));
FileUtil.deleteFile(blockFile);
}
}
}
BufferedRandomAccessFile file = null;
try {
if (totalThreadNum > 1 && !record.isBlock) {
file = new BufferedRandomAccessFile(new File(getTempFile().getPath()), "rwd", 8192);
//设置文件长度
file.setLength(getEntity().getFileSize());
}
return true;
} catch (IOException e) {
e.printStackTrace();
ALog.e(TAG, String.format("下载失败filePath: %s, url: %s", getEntity().getFilePath(),
getEntity().getUrl()));
} finally {
if (file != null) {
try {
file.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return false;
}
@Override public IThreadTask createThreadTask(SubThreadConfig config) {
ThreadTask task = new ThreadTask(config);
HttpDThreadTaskAdapter adapter = new HttpDThreadTaskAdapter(config);
task.setAdapter(adapter);
return task;
}
@Override public IRecordHandler recordHandler(AbsTaskWrapper wrapper) {
RecordHandler recordHandler = new RecordHandler(wrapper);
HttpRecordAdapter adapter = new HttpRecordAdapter(wrapper);
recordHandler.setAdapter(adapter);
return recordHandler;
}
private DownloadEntity getEntity() {
return (DownloadEntity) getWrapper().getEntity();
}
}
///*
// * 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.http.download;
//
//import com.arialyy.aria.core.TaskRecord;
//import com.arialyy.aria.core.common.RecordHandler;
//import com.arialyy.aria.core.common.SubThreadConfig;
//import com.arialyy.aria.core.download.DownloadEntity;
//import com.arialyy.aria.core.loader.IRecordHandler;
//import com.arialyy.aria.core.task.AbsNormalLoaderAdapter;
//import com.arialyy.aria.core.task.IThreadTask;
//import com.arialyy.aria.core.task.ThreadTask;
//import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
//import com.arialyy.aria.core.wrapper.ITaskWrapper;
//import com.arialyy.aria.http.HttpRecordHandler;
//import com.arialyy.aria.util.ALog;
//import com.arialyy.aria.util.BufferedRandomAccessFile;
//import com.arialyy.aria.util.FileUtil;
//import java.io.File;
//import java.io.IOException;
//
///**
// * @Author lyy
// * @Date 2019-09-21
// */
//final class HttpDLoaderAdapter extends AbsNormalLoaderAdapter {
// HttpDLoaderAdapter(ITaskWrapper wrapper) {
// super(wrapper);
// }
//
// @Override public boolean handleNewTask(TaskRecord record, int totalThreadNum) {
// if (!record.isBlock) {
// if (getTempFile().exists()) {
// FileUtil.deleteFile(getTempFile());
// }
// } else {
// for (int i = 0; i < totalThreadNum; i++) {
// File blockFile =
// new File(String.format(IRecordHandler.SUB_PATH, getTempFile().getPath(), i));
// if (blockFile.exists()) {
// ALog.d(TAG, String.format("分块【%s】已经存在将删除该分块", i));
// FileUtil.deleteFile(blockFile);
// }
// }
// }
// BufferedRandomAccessFile file = null;
// try {
// if (totalThreadNum > 1 && !record.isBlock) {
// file = new BufferedRandomAccessFile(new File(getTempFile().getPath()), "rwd", 8192);
// //设置文件长度
// file.setLength(getEntity().getFileSize());
// }
// return true;
// } catch (IOException e) {
// e.printStackTrace();
// ALog.e(TAG, String.format("下载失败filePath: %s, url: %s", getEntity().getFilePath(),
// getEntity().getUrl()));
// } finally {
// if (file != null) {
// try {
// file.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// return false;
// }
//
// @Override public IThreadTask createThreadTask(SubThreadConfig config) {
// ThreadTask task = new ThreadTask(config);
// HttpDThreadTaskAdapter adapter = new HttpDThreadTaskAdapter(config);
// task.setAdapter(adapter);
// return task;
// }
//
// @Override public IRecordHandler recordHandler(AbsTaskWrapper wrapper) {
// RecordHandler recordHandler = new RecordHandler(wrapper);
// HttpRecordHandler adapter = new HttpRecordHandler(wrapper);
// recordHandler.setAdapter(adapter);
// return recordHandler;
// }
//
// private DownloadEntity getEntity() {
// return (DownloadEntity) getWrapper().getEntity();
// }
//}

View File

@@ -15,17 +15,16 @@
*/
package com.arialyy.aria.http.download;
import com.arialyy.aria.core.common.AbsEntity;
import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.inf.OnFileInfoCallback;
import com.arialyy.aria.core.listener.IEventListener;
import com.arialyy.aria.core.loader.AbsLoader;
import com.arialyy.aria.core.loader.AbsNormalLoaderUtil;
import com.arialyy.aria.core.loader.LoaderStructure;
import com.arialyy.aria.core.loader.NormalLoader;
import com.arialyy.aria.core.loader.ThreadStateManager;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.http.HttpFileInfoThread;
import com.arialyy.aria.http.HttpFileInfoTask;
import com.arialyy.aria.http.HttpRecordHandler;
import com.arialyy.aria.http.HttpTaskOption;
/**
@@ -38,24 +37,17 @@ public class HttpDLoaderUtil extends AbsNormalLoaderUtil {
wrapper.generateTaskOption(HttpTaskOption.class);
}
@Override protected AbsLoader createLoader() {
NormalLoader loader = new NormalLoader(getListener(), getTaskWrapper());
HttpDLoaderAdapter adapter = new HttpDLoaderAdapter(getTaskWrapper());
loader.setAdapter(adapter);
return loader;
@Override public AbsLoader getLoader() {
return mLoader == null ? new NormalLoader(getTaskWrapper(), getListener()) : mLoader;
}
@Override protected Runnable createInfoThread() {
return new HttpFileInfoThread((DTaskWrapper) getTaskWrapper(), new OnFileInfoCallback() {
@Override public void onComplete(String url, CompleteInfo info) {
((NormalLoader) getLoader()).updateTempFile();
getLoader().start();
}
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
fail(e, needRetry);
getLoader().closeTimer();
}
});
public LoaderStructure getLoaderStructure() {
LoaderStructure structure = new LoaderStructure();
structure.addComponent(new HttpRecordHandler(getTaskWrapper()))
.addComponent(new ThreadStateManager(getListener()))
.addComponent(new HttpFileInfoTask((DTaskWrapper) getTaskWrapper()))
.addComponent(new HttpDTTBuilder(getTaskWrapper()));
structure.accept(getLoader());
return structure;
}
}

View File

@@ -0,0 +1,62 @@
package com.arialyy.aria.http.download;
import com.arialyy.aria.core.TaskRecord;
import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.loader.AbsNormalTTBuilder;
import com.arialyy.aria.core.loader.IRecordHandler;
import com.arialyy.aria.core.task.IThreadTaskAdapter;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.BufferedRandomAccessFile;
import com.arialyy.aria.util.FileUtil;
import java.io.File;
import java.io.IOException;
final class HttpDTTBuilder extends AbsNormalTTBuilder {
HttpDTTBuilder(AbsTaskWrapper wrapper) {
super(wrapper);
}
@Override public IThreadTaskAdapter getAdapter(SubThreadConfig config) {
return new HttpDThreadTaskAdapter(config);
}
@Override public boolean handleNewTask(TaskRecord record, int totalThreadNum) {
if (!record.isBlock) {
if (getTempFile().exists()) {
FileUtil.deleteFile(getTempFile());
}
} else {
for (int i = 0; i < totalThreadNum; i++) {
File blockFile =
new File(String.format(IRecordHandler.SUB_PATH, getTempFile().getPath(), i));
if (blockFile.exists()) {
ALog.d(TAG, String.format("分块【%s】已经存在将删除该分块", i));
FileUtil.deleteFile(blockFile);
}
}
}
BufferedRandomAccessFile file = null;
try {
if (totalThreadNum > 1 && !record.isBlock) {
file = new BufferedRandomAccessFile(new File(getTempFile().getPath()), "rwd", 8192);
//设置文件长度
file.setLength(getEntity().getFileSize());
}
return true;
} catch (IOException e) {
e.printStackTrace();
ALog.e(TAG, String.format("下载失败filePath: %s, url: %s", getEntity().getFilePath(),
getEntity().getUrl()));
} finally {
if (file != null) {
try {
file.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return false;
}
}

View File

@@ -25,7 +25,7 @@ import com.arialyy.aria.core.inf.OnFileInfoCallback;
import com.arialyy.aria.core.listener.ISchedulers;
import com.arialyy.aria.core.loader.NormalLoader;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.http.HttpFileInfoThread;
import com.arialyy.aria.http.HttpFileInfoTask;
/**
* @Author lyy
@@ -49,7 +49,7 @@ class HttpSubDLoaderUtil extends AbsSubDLoadUtil {
@Override public void start() {
if (isNeedGetInfo()) {
new Thread(new HttpFileInfoThread(getWrapper(), new OnFileInfoCallback() {
new Thread(new HttpFileInfoTask(getWrapper(), new OnFileInfoCallback() {
@Override public void onComplete(String url, CompleteInfo info) {
getDownloader().start();

View File

@@ -18,13 +18,13 @@ package com.arialyy.aria.http.upload;
import com.arialyy.aria.core.TaskRecord;
import com.arialyy.aria.core.common.RecordHandler;
import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.inf.IRecordHandler;
import com.arialyy.aria.core.loader.IRecordHandler;
import com.arialyy.aria.core.task.AbsNormalLoaderAdapter;
import com.arialyy.aria.core.task.IThreadTask;
import com.arialyy.aria.core.task.ThreadTask;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.http.HttpRecordAdapter;
import com.arialyy.aria.http.HttpRecordHandler;
/**
* @Author lyy
@@ -48,7 +48,7 @@ final class HttpULoaderAdapter extends AbsNormalLoaderAdapter {
@Override public IRecordHandler recordHandler(AbsTaskWrapper wrapper) {
RecordHandler recordHandler = new RecordHandler(wrapper);
HttpRecordAdapter adapter = new HttpRecordAdapter(wrapper);
HttpRecordHandler adapter = new HttpRecordHandler(wrapper);
recordHandler.setAdapter(adapter);
return recordHandler;
}