添加Serializable接口支持 https://github.com/AriaLyy/Aria/issues/320 失败回调增加错误原因 https://github.com/AriaLyy/Aria/issues/310
This commit is contained in:
@@ -21,6 +21,9 @@ import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||
import com.arialyy.aria.core.inf.IEventListener;
|
||||
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.exception.FileException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.ErrorHelp;
|
||||
import com.arialyy.aria.util.FileUtil;
|
||||
@@ -94,6 +97,7 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
|
||||
|
||||
/**
|
||||
* 设置线程是否中断
|
||||
*
|
||||
* @param isInterrupted {@code true} 中断
|
||||
*/
|
||||
public void setInterrupted(boolean isInterrupted) {
|
||||
@@ -102,9 +106,10 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
|
||||
|
||||
/**
|
||||
* 线程是否存活
|
||||
*
|
||||
* @return {@code true}存活
|
||||
*/
|
||||
protected boolean isLive(){
|
||||
protected boolean isLive() {
|
||||
Thread t = Thread.currentThread();
|
||||
return !t.isInterrupted() && !isInterrupted;
|
||||
}
|
||||
@@ -265,10 +270,11 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
|
||||
protected void progress(long len) {
|
||||
synchronized (AriaManager.LOCK) {
|
||||
if (STATE.CURRENT_LOCATION > mEntity.getFileSize()) {
|
||||
ALog.d(TAG, String.format("currentLocation=%s, fileSize=%s", STATE.CURRENT_LOCATION,
|
||||
mEntity.getFileSize()));
|
||||
String errorMsg =
|
||||
String.format("下载失败,下载长度超出文件大;currentLocation=%s, fileSize=%s", STATE.CURRENT_LOCATION,
|
||||
mEntity.getFileSize());
|
||||
taskBreak = true;
|
||||
fail(mChildCurrentLocation, "下载失败,下载长度超出文件大小", null, false);
|
||||
fail(mChildCurrentLocation, new FileException(TAG, errorMsg), false);
|
||||
return;
|
||||
}
|
||||
mChildCurrentLocation += len;
|
||||
@@ -312,11 +318,10 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
|
||||
* 线程任务失败
|
||||
*
|
||||
* @param subCurrentLocation 当前线程下载进度
|
||||
* @param msg 自定义信息
|
||||
* @param ex 异常信息
|
||||
*/
|
||||
protected void fail(final long subCurrentLocation, String msg, Exception ex) {
|
||||
fail(subCurrentLocation, msg, ex, true);
|
||||
protected void fail(final long subCurrentLocation, BaseException ex) {
|
||||
fail(subCurrentLocation, ex, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,19 +329,17 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
|
||||
*
|
||||
* @param subCurrentLocation 当前子线程进度
|
||||
*/
|
||||
protected void fail(final long subCurrentLocation, String msg, Exception ex, boolean needRetry) {
|
||||
protected void fail(final long subCurrentLocation, BaseException ex, boolean needRetry) {
|
||||
synchronized (AriaManager.LOCK) {
|
||||
if (ex != null) {
|
||||
ALog.e(TAG, msg + "\n" + ALog.getExceptionString(ex));
|
||||
} else {
|
||||
ALog.e(TAG, msg);
|
||||
ALog.e(TAG, ALog.getExceptionString(ex));
|
||||
}
|
||||
if (mConfig.SUPPORT_BP) {
|
||||
writeConfig(false, subCurrentLocation);
|
||||
retryThis(needRetry && STATE.START_THREAD_NUM != 1);
|
||||
} else {
|
||||
ALog.e(TAG, String.format("任务【%s】执行失败", mConfig.TEMP_FILE.getName()));
|
||||
mListener.onFail(true);
|
||||
mListener.onFail(true, ex);
|
||||
ErrorHelp.saveError(TAG, "", ALog.getExceptionString(ex));
|
||||
}
|
||||
}
|
||||
@@ -424,8 +427,9 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
|
||||
STATE.isRunning = false;
|
||||
// 手动停止不进行fail回调
|
||||
if (!STATE.isStop) {
|
||||
ALog.e(TAG, String.format("任务【%s】执行失败", mConfig.TEMP_FILE.getName()));
|
||||
mListener.onFail(taskNeedReTry);
|
||||
String errorMsg = String.format("任务【%s】执行失败", mConfig.TEMP_FILE.getName());
|
||||
//ALog.e(TAG, errorMsg);
|
||||
mListener.onFail(taskNeedReTry, new TaskException(TAG, errorMsg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,10 @@ import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.core.inf.IEventListener;
|
||||
import com.arialyy.aria.core.inf.TaskSchedulerType;
|
||||
import com.arialyy.aria.core.scheduler.ISchedulers;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.aria.util.ErrorHelp;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public abstract class BaseListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>, TASK extends AbsTask<ENTITY, TASK_ENTITY>>
|
||||
@@ -103,12 +106,14 @@ public abstract class BaseListener<ENTITY extends AbsEntity, TASK_ENTITY extends
|
||||
sendInState2Target(ISchedulers.CANCEL);
|
||||
}
|
||||
|
||||
@Override public void onFail(boolean needRetry) {
|
||||
@Override public void onFail(boolean needRetry, BaseException e) {
|
||||
mEntity.setFailNum(mEntity.getFailNum() + 1);
|
||||
saveData(IEntity.STATE_FAIL, mEntity.getCurrentProgress());
|
||||
handleSpeed(0);
|
||||
mTask.needRetry = needRetry;
|
||||
sendInState2Target(ISchedulers.FAIL);
|
||||
e.printStackTrace();
|
||||
ErrorHelp.saveError(e.getTag(), "", ALog.getExceptionString(e));
|
||||
}
|
||||
|
||||
private void handleSpeed(long speed) {
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.common;
|
||||
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
|
||||
public interface OnFileInfoCallback {
|
||||
/**
|
||||
* 处理完成
|
||||
@@ -26,7 +28,7 @@ public interface OnFileInfoCallback {
|
||||
/**
|
||||
* 请求失败
|
||||
*
|
||||
* @param errorMsg 错误信息
|
||||
* @param e 错误信息
|
||||
*/
|
||||
void onFail(String url, String errorMsg, boolean needRetry);
|
||||
void onFail(String url, BaseException e, boolean needRetry);
|
||||
}
|
||||
@@ -23,6 +23,10 @@ import com.arialyy.aria.core.common.ProtocolType;
|
||||
import com.arialyy.aria.core.inf.AbsEntity;
|
||||
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.exception.AriaIOException;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.exception.FileException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.Regular;
|
||||
import com.arialyy.aria.util.SSLContextUtil;
|
||||
@@ -90,8 +94,9 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
|
||||
FTPFile[] files = client.listFiles(remotePath);
|
||||
boolean isExist = files.length != 0;
|
||||
if (!isExist && !isUpload) {
|
||||
failDownload(String.format("文件不存在,任务链接【%s】,remotePath:%s", mTaskEntity.getUrlEntity().url,
|
||||
remotePath), false);
|
||||
failDownload(new FileException(TAG,
|
||||
String.format("文件不存在,url: %s, remotePath:%s", mTaskEntity.getUrlEntity().url,
|
||||
remotePath)), false);
|
||||
int i = remotePath.lastIndexOf(File.separator);
|
||||
FTPFile[] files1;
|
||||
if (i == -1) {
|
||||
@@ -122,8 +127,9 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
|
||||
mTaskEntity.setNewTask(true);
|
||||
} else {
|
||||
client.disconnect();
|
||||
failDownload(String.format("获取文件信息错误,错误码为:%s,msg:%s", reply, client.getReplyString()),
|
||||
true);
|
||||
failDownload(new AriaIOException(TAG,
|
||||
String.format("获取文件信息错误,url: %s, errorCode:%s, errorMsg:%s",
|
||||
mTaskEntity.getUrlEntity().url, reply, client.getReplyString())), true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -134,10 +140,9 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
|
||||
mTaskEntity.update();
|
||||
onPreComplete(reply);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
ALog.e(TAG,
|
||||
String.format("FTP错误信息,code:%s,msg:%s", client.getReplyCode(), client.getReplyString()));
|
||||
failDownload(e.getMessage(), true);
|
||||
failDownload(new AriaIOException(TAG,
|
||||
String.format("FTP错误信息,code:%s,msg:%s", client.getReplyCode(), client.getReplyString()),
|
||||
e), true);
|
||||
} finally {
|
||||
closeClient(client);
|
||||
}
|
||||
@@ -195,7 +200,8 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
|
||||
}
|
||||
|
||||
if (client == null) {
|
||||
failDownload("链接失败", false);
|
||||
failDownload(new AriaIOException(TAG,
|
||||
String.format("链接失败, url: %s", mTaskEntity.getUrlEntity().url)), false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -208,15 +214,17 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
|
||||
loginSuccess = client.login(urlEntity.user, urlEntity.password, urlEntity.account);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
ALog.e(TAG, String.format("登录失败,错误码为:%s, msg:%s", client.getReplyCode(),
|
||||
client.getReplyString()));
|
||||
ALog.e(TAG,
|
||||
new TaskException(TAG, String.format("登录失败,错误码为:%s, msg:%s", client.getReplyCode(),
|
||||
client.getReplyString()), e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!loginSuccess) {
|
||||
failDownload(
|
||||
String.format("登录失败,错误码为:%s, msg:%s", client.getReplyCode(), client.getReplyString()),
|
||||
new TaskException(TAG, String.format("登录失败,错误码为:%s, msg:%s", client.getReplyCode(),
|
||||
client.getReplyString())),
|
||||
false);
|
||||
client.disconnect();
|
||||
return null;
|
||||
@@ -225,7 +233,9 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
|
||||
int reply = client.getReplyCode();
|
||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||
client.disconnect();
|
||||
failDownload(String.format("无法连接到ftp服务器,错误码为:%s,msg:%s", reply, client.getReplyString()),
|
||||
failDownload(new AriaIOException(TAG,
|
||||
String.format("无法连接到ftp服务器,filePath: %s, url: %s, errorCode: %s, errorMsg:%s",
|
||||
mEntity.getKey(), mTaskEntity.getUrlEntity().url, reply, client.getReplyString())),
|
||||
true);
|
||||
return null;
|
||||
}
|
||||
@@ -353,10 +363,9 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
|
||||
protected void handleFile(String remotePath, FTPFile ftpFile) {
|
||||
}
|
||||
|
||||
private void failDownload(String errorMsg, boolean needRetry) {
|
||||
ALog.e(TAG, errorMsg);
|
||||
private void failDownload(BaseException e, boolean needRetry) {
|
||||
if (mCallback != null) {
|
||||
mCallback.onFail(mEntity.getKey(), errorMsg, needRetry);
|
||||
mCallback.onFail(mEntity.getKey(), e, needRetry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.arialyy.aria.core.common.ftp;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.FtpUrlEntity;
|
||||
import com.arialyy.aria.core.common.AbsThreadTask;
|
||||
import com.arialyy.aria.core.common.ProtocolType;
|
||||
@@ -25,9 +24,9 @@ import com.arialyy.aria.core.common.SubThreadConfig;
|
||||
import com.arialyy.aria.core.inf.AbsNormalEntity;
|
||||
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||
import com.arialyy.aria.core.inf.IEventListener;
|
||||
import com.arialyy.aria.exception.AriaIOException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.SSLContextUtil;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import javax.net.ssl.SSLContext;
|
||||
@@ -74,7 +73,7 @@ public abstract class AbsFtpThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTI
|
||||
client = newInstanceClient(urlEntity);
|
||||
try {
|
||||
client.connect(urlEntity.validAddr, Integer.parseInt(urlEntity.port));
|
||||
} catch (IOException e) {
|
||||
} catch (java.io.IOException e) {
|
||||
ALog.e(TAG, ALog.getExceptionString(e));
|
||||
return null;
|
||||
}
|
||||
@@ -101,8 +100,8 @@ public abstract class AbsFtpThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTI
|
||||
int reply = client.getReplyCode();
|
||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||
client.disconnect();
|
||||
fail(mChildCurrentLocation,
|
||||
String.format("无法连接到ftp服务器,错误码为:%s,msg:%s", reply, client.getReplyString()), null);
|
||||
fail(mChildCurrentLocation, new AriaIOException(TAG,
|
||||
String.format("无法连接到ftp服务器,错误码为:%s,msg:%s", reply, client.getReplyString())), false);
|
||||
return null;
|
||||
}
|
||||
// 开启服务器对UTF-8的支持,如果服务器支持就用UTF-8编码
|
||||
@@ -121,7 +120,7 @@ public abstract class AbsFtpThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTI
|
||||
if (mTaskEntity.getUrlEntity().isFtps) {
|
||||
((FTPSClient) client).execPROT("P");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (java.io.IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return client;
|
||||
@@ -154,12 +153,12 @@ public abstract class AbsFtpThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTI
|
||||
client.connect(ips[index], port);
|
||||
mTaskEntity.getUrlEntity().validAddr = ips[index];
|
||||
return client;
|
||||
} catch (IOException e) {
|
||||
} catch (java.io.IOException e) {
|
||||
try {
|
||||
if (client.isConnected()) {
|
||||
client.disconnect();
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
} catch (java.io.IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (index + 1 >= ips.length) {
|
||||
|
||||
@@ -21,8 +21,10 @@ import com.arialyy.aria.core.download.downloader.IDownloadGroupListener;
|
||||
import com.arialyy.aria.core.inf.GroupSendParams;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.core.scheduler.ISchedulers;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.aria.util.ErrorHelp;
|
||||
|
||||
/**
|
||||
* Created by Aria.Lao on 2017/7/20.
|
||||
@@ -64,9 +66,11 @@ class DownloadGroupListener
|
||||
sendInState2Target(ISchedulers.SUB_COMPLETE, subEntity);
|
||||
}
|
||||
|
||||
@Override public void onSubFail(DownloadEntity subEntity) {
|
||||
@Override public void onSubFail(DownloadEntity subEntity, BaseException e) {
|
||||
saveCurrentLocation();
|
||||
sendInState2Target(ISchedulers.SUB_FAIL, subEntity);
|
||||
e.printStackTrace();
|
||||
ErrorHelp.saveError(e.getTag(), "", ALog.getExceptionString(e));
|
||||
}
|
||||
|
||||
@Override public void onSubCancel(DownloadEntity subEntity) {
|
||||
|
||||
@@ -22,6 +22,8 @@ import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
|
||||
import com.arialyy.aria.core.download.DownloadTaskEntity;
|
||||
import com.arialyy.aria.core.inf.IDownloadListener;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.aria.util.NetUtils;
|
||||
@@ -482,7 +484,7 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onFail(boolean needRetry) {
|
||||
@Override public void onFail(boolean needRetry, BaseException e) {
|
||||
subEntity.setFailNum(subEntity.getFailNum() + 1);
|
||||
saveData(IEntity.STATE_FAIL, lastLen);
|
||||
handleSpeed(0);
|
||||
@@ -504,12 +506,15 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
|
||||
reStartTask(dt);
|
||||
} else {
|
||||
mFailMap.put(subTaskEntity.getUrl(), subTaskEntity);
|
||||
mListener.onSubFail(subEntity);
|
||||
mListener.onSubFail(subEntity, new TaskException(TAG,
|
||||
String.format("任务组子任务【%s】下载失败,下载地址【%s】", subEntity.getFileName(),
|
||||
subEntity.getUrl())));
|
||||
if (mFailMap.size() == mExeMap.size() || mFailMap.size() + mCompleteNum == mGroupSize) {
|
||||
closeTimer();
|
||||
}
|
||||
if (mFailMap.size() == mGroupSize) {
|
||||
mListener.onFail(true);
|
||||
mListener.onFail(true, new TaskException(TAG,
|
||||
String.format("任务组【%s】下载失败", mGTEntity.getEntity().getGroupName())));
|
||||
} else if (mFailMap.size() + mCompleteNum >= mExeMap.size()) {
|
||||
mListener.onStop(mCurrentLocation);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import com.arialyy.aria.core.common.OnFileInfoCallback;
|
||||
import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
|
||||
import com.arialyy.aria.core.download.DownloadTaskEntity;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -85,8 +87,8 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
|
||||
}
|
||||
|
||||
if (mExeMap.size() == 0) {
|
||||
ALog.e(TAG, "任务组无可执行任务");
|
||||
mListener.onFail(false);
|
||||
mListener.onFail(false, new TaskException(TAG,
|
||||
String.format("任务组【%s】无可执行任务", mGTEntity.getEntity().getGroupName())));
|
||||
return;
|
||||
}
|
||||
Set<String> keys = mExeMap.keySet();
|
||||
@@ -133,7 +135,7 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
|
||||
checkStartFlow();
|
||||
}
|
||||
|
||||
@Override public void onFail(String url, String errorMsg, boolean needRetry) {
|
||||
@Override public void onFail(String url, BaseException e, boolean needRetry) {
|
||||
if (isStop) return;
|
||||
ALog.e(TAG, String.format("任务【%s】初始化失败", url));
|
||||
DownloadTaskEntity te = mExeMap.get(url);
|
||||
@@ -169,7 +171,8 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
|
||||
}
|
||||
if (mInitFailNum == mExeNum) {
|
||||
closeTimer();
|
||||
mListener.onFail(true);
|
||||
mListener.onFail(true, new TaskException(TAG,
|
||||
String.format("任务组【%s】初始化失败", mGTEntity.getEntity().getGroupName())));
|
||||
}
|
||||
if (!isStart && mInitCompleteNum + mInitFailNum == mExeNum || !isNeedLoadFileSize) {
|
||||
startRunningFlow();
|
||||
|
||||
@@ -23,10 +23,9 @@ import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.DownloadTaskEntity;
|
||||
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||
import com.arialyy.aria.core.inf.IDownloadListener;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.aria.util.ErrorHelp;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -58,7 +57,7 @@ class Downloader extends AbsFileer<DownloadEntity, DownloadTaskEntity> {
|
||||
|
||||
@Override protected boolean handleNewTask() {
|
||||
if (!mRecord.isBlock) {
|
||||
if (mTempFile.exists()){
|
||||
if (mTempFile.exists()) {
|
||||
mTempFile.delete();
|
||||
}
|
||||
//CommonUtil.createFile(mTempFile.getPath());
|
||||
@@ -72,8 +71,9 @@ class Downloader extends AbsFileer<DownloadEntity, DownloadTaskEntity> {
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
failDownload(String.format("下载失败【downloadUrl:%s】;【filePath:%s】\n %S", mEntity.getUrl(),
|
||||
mEntity.getDownloadPath(), ALog.getExceptionString(e)));
|
||||
failDownload(new TaskException(TAG,
|
||||
String.format("下载失败,filePath: %s, url: %s", mEntity.getDownloadPath(),
|
||||
mEntity.getUrl()), e));
|
||||
} finally {
|
||||
if (file != null) {
|
||||
try {
|
||||
@@ -106,11 +106,9 @@ class Downloader extends AbsFileer<DownloadEntity, DownloadTaskEntity> {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void failDownload(String errorMsg) {
|
||||
private void failDownload(BaseException e) {
|
||||
closeTimer();
|
||||
ALog.e(TAG, errorMsg);
|
||||
mConstance.isRunning = false;
|
||||
mListener.onFail(false);
|
||||
ErrorHelp.saveError(TAG, "", errorMsg);
|
||||
mListener.onFail(false, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ import com.arialyy.aria.core.common.CompleteInfo;
|
||||
import com.arialyy.aria.core.common.OnFileInfoCallback;
|
||||
import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
|
||||
import com.arialyy.aria.core.download.DownloadTaskEntity;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.ErrorHelp;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -51,14 +53,13 @@ public class FtpDirDownloadUtil extends AbsGroupUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onFail(String url, String errorMsg, boolean needRetry) {
|
||||
@Override public void onFail(String url, BaseException e, boolean needRetry) {
|
||||
DownloadTaskEntity te = mExeMap.get(url);
|
||||
if (te != null) {
|
||||
mFailMap.put(url, te);
|
||||
mExeMap.remove(url);
|
||||
}
|
||||
mListener.onFail(needRetry);
|
||||
ErrorHelp.saveError(TAG, "", errorMsg);
|
||||
mListener.onFail(needRetry, e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.arialyy.aria.core.common.OnFileInfoCallback;
|
||||
import com.arialyy.aria.core.common.ftp.AbsFtpInfoThread;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.DownloadTaskEntity;
|
||||
import com.arialyy.aria.exception.AriaIOException;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
|
||||
@@ -28,6 +29,7 @@ import org.apache.commons.net.ftp.FTPFile;
|
||||
* 获取ftp文件信息
|
||||
*/
|
||||
class FtpFileInfoThread extends AbsFtpInfoThread<DownloadEntity, DownloadTaskEntity> {
|
||||
private final String TAG = "FtpFileInfoThread";
|
||||
|
||||
FtpFileInfoThread(DownloadTaskEntity taskEntity, OnFileInfoCallback callback) {
|
||||
super(taskEntity, callback);
|
||||
@@ -36,7 +38,9 @@ class FtpFileInfoThread extends AbsFtpInfoThread<DownloadEntity, DownloadTaskEnt
|
||||
@Override protected void handleFile(String remotePath, FTPFile ftpFile) {
|
||||
super.handleFile(remotePath, ftpFile);
|
||||
if (!CommonUtil.checkSDMemorySpace(mEntity.getDownloadPath(), ftpFile.getSize())) {
|
||||
mCallback.onFail(mEntity.getUrl(), String.format("路径【%s】内存空间不足", mEntity.getDownloadPath()),
|
||||
mCallback.onFail(mEntity.getUrl(),
|
||||
new AriaIOException(TAG,
|
||||
String.format("获取ftp文件信息失败,内存空间不足, filePath: %s", mEntity.getDownloadPath())),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import com.arialyy.aria.core.common.ftp.AbsFtpThreadTask;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.DownloadTaskEntity;
|
||||
import com.arialyy.aria.core.inf.IDownloadListener;
|
||||
import com.arialyy.aria.exception.AriaIOException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -69,7 +71,7 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
|
||||
mConfig.THREAD_ID, mConfig.START_LOCATION, mConfig.END_LOCATION));
|
||||
client = createClient();
|
||||
if (client == null) {
|
||||
fail(mChildCurrentLocation, "ftp client 创建失败", null);
|
||||
fail(mChildCurrentLocation, new TaskException(TAG, "ftp client 创建失败"));
|
||||
return this;
|
||||
}
|
||||
if (mConfig.START_LOCATION > 0) {
|
||||
@@ -79,8 +81,8 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
|
||||
int reply = client.getReplyCode();
|
||||
if (!FTPReply.isPositivePreliminary(reply) && reply != FTPReply.COMMAND_OK) {
|
||||
fail(mChildCurrentLocation,
|
||||
String.format("获取文件信息错误,错误码为:%s,msg:%s", reply, client.getReplyString()),
|
||||
null);
|
||||
new AriaIOException(TAG,
|
||||
String.format("获取文件信息错误,错误码为:%s,msg:%s", reply, client.getReplyString())));
|
||||
client.disconnect();
|
||||
return this;
|
||||
}
|
||||
@@ -91,8 +93,8 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
|
||||
reply = client.getReplyCode();
|
||||
if (!FTPReply.isPositivePreliminary(reply)) {
|
||||
fail(mChildCurrentLocation,
|
||||
String.format("获取流失败,错误码为:%s,msg:%s", reply, client.getReplyString()),
|
||||
null);
|
||||
new AriaIOException(TAG,
|
||||
String.format("获取流失败,错误码为:%s,msg:%s", reply, client.getReplyString())));
|
||||
client.disconnect();
|
||||
return this;
|
||||
}
|
||||
@@ -104,9 +106,11 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
|
||||
handleComplete();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
fail(mChildCurrentLocation, String.format("下载失败【%s】", mConfig.URL), e);
|
||||
fail(mChildCurrentLocation,
|
||||
new AriaIOException(TAG, String.format("下载失败【%s】", mConfig.URL), e));
|
||||
} catch (Exception e) {
|
||||
fail(mChildCurrentLocation, "获取流失败", e);
|
||||
fail(mChildCurrentLocation,
|
||||
new AriaIOException(TAG, String.format("下载失败【%s】", mConfig.URL), e));
|
||||
} finally {
|
||||
try {
|
||||
if (is != null) {
|
||||
@@ -137,9 +141,10 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
|
||||
if (isBlock) {
|
||||
boolean success = mergeFile();
|
||||
if (!success) {
|
||||
ALog.e(TAG, String.format("任务【%s】分块文件合并失败", mConfig.TEMP_FILE.getName()));
|
||||
//ALog.e(TAG, String.format("任务【%s】分块文件合并失败", mConfig.TEMP_FILE.getName()));
|
||||
STATE.isRunning = false;
|
||||
mListener.onFail(false);
|
||||
mListener.onFail(false,
|
||||
new TaskException(TAG, String.format("任务【%s】分块文件合并失败", mConfig.TEMP_FILE.getName())));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -149,7 +154,8 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
|
||||
}
|
||||
if (STATE.isFail()) {
|
||||
STATE.isRunning = false;
|
||||
mListener.onFail(false);
|
||||
mListener.onFail(false,
|
||||
new TaskException(TAG, String.format("任务【%s】下载失败", mConfig.TEMP_FILE.getName())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +195,8 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
|
||||
}
|
||||
handleComplete();
|
||||
} catch (IOException e) {
|
||||
fail(mChildCurrentLocation, String.format("下载失败【%s】", mConfig.URL), e);
|
||||
fail(mChildCurrentLocation,
|
||||
new AriaIOException(TAG, String.format("下载失败【%s】", mConfig.URL), e));
|
||||
} finally {
|
||||
try {
|
||||
if (fos != null) {
|
||||
@@ -235,7 +242,8 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
fail(mChildCurrentLocation, String.format("下载失败【%s】", mConfig.URL), e);
|
||||
fail(mChildCurrentLocation,
|
||||
new AriaIOException(TAG, String.format("下载失败【%s】", mConfig.URL), e));
|
||||
} finally {
|
||||
try {
|
||||
if (file != null) {
|
||||
|
||||
@@ -22,6 +22,9 @@ import com.arialyy.aria.core.common.OnFileInfoCallback;
|
||||
import com.arialyy.aria.core.common.RequestEnum;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.DownloadTaskEntity;
|
||||
import com.arialyy.aria.exception.AriaIOException;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CheckUtil;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
@@ -67,12 +70,9 @@ class HttpFileInfoThread implements Runnable {
|
||||
conn.connect();
|
||||
handleConnect(conn);
|
||||
} catch (IOException e) {
|
||||
failDownload("下载失败【downloadUrl:"
|
||||
+ mEntity.getUrl()
|
||||
+ "】\n【filePath:"
|
||||
+ mEntity.getDownloadPath()
|
||||
+ "】\n"
|
||||
+ ALog.getExceptionString(e), true);
|
||||
failDownload(new AriaIOException(TAG,
|
||||
String.format("下载失败,filePath: %s, url: %s", mEntity.getDownloadPath(), mEntity.getUrl())),
|
||||
true);
|
||||
} finally {
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
@@ -116,7 +116,9 @@ class HttpFileInfoThread implements Runnable {
|
||||
}
|
||||
|
||||
if (!CommonUtil.checkSDMemorySpace(mEntity.getDownloadPath(), len)) {
|
||||
failDownload(String.format("路径【%s】内存空间不足", mEntity.getDownloadPath()), false);
|
||||
failDownload(new TaskException(TAG,
|
||||
String.format("下载失败,内存空间不足;filePath: %s, url: %s", mEntity.getDownloadPath(),
|
||||
mEntity.getUrl())), false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -184,14 +186,16 @@ class HttpFileInfoThread implements Runnable {
|
||||
mTaskEntity.setSupportBP(false);
|
||||
end = true;
|
||||
} else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
|
||||
failDownload("任务【" + mEntity.getUrl() + "】下载失败,错误码:404", true);
|
||||
failDownload(new AriaIOException(TAG,
|
||||
String.format("任务下载失败,errorCode:404, url: %s", mEntity.getUrl())), true);
|
||||
} else if (code == HttpURLConnection.HTTP_MOVED_TEMP
|
||||
|| code == HttpURLConnection.HTTP_MOVED_PERM
|
||||
|| code == HttpURLConnection.HTTP_SEE_OTHER
|
||||
|| code == 307) {
|
||||
handleUrlReTurn(conn, conn.getHeaderField("Location"));
|
||||
} else {
|
||||
failDownload("任务【" + mEntity.getUrl() + "】下载失败,错误码:" + code, true);
|
||||
failDownload(new AriaIOException(TAG,
|
||||
String.format("任务下载失败,errorCode:%s, url: %s", code, mEntity.getUrl())), true);
|
||||
}
|
||||
if (end) {
|
||||
mTaskEntity.setChunked(isChunked);
|
||||
@@ -229,12 +233,12 @@ class HttpFileInfoThread implements Runnable {
|
||||
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null") || !newUrl.startsWith(
|
||||
"http")) {
|
||||
if (onFileInfoCallback != null) {
|
||||
onFileInfoCallback.onFail(mEntity.getUrl(), "获取重定向链接失败", false);
|
||||
onFileInfoCallback.onFail(mEntity.getUrl(), new TaskException(TAG, "获取重定向链接失败"), false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!CheckUtil.checkUrl(newUrl)) {
|
||||
failDownload("下载失败,重定向url错误", false);
|
||||
failDownload(new TaskException(TAG, "下载失败,重定向url错误"), false);
|
||||
return;
|
||||
}
|
||||
mTaskEntity.setRedirectUrl(newUrl);
|
||||
@@ -263,16 +267,17 @@ class HttpFileInfoThread implements Runnable {
|
||||
mTaskEntity.setNewTask(true);
|
||||
}
|
||||
if (len < 0) {
|
||||
failDownload("任务【" + mEntity.getUrl() + "】下载失败,文件长度小于0", true);
|
||||
failDownload(
|
||||
new AriaIOException(TAG, String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
|
||||
true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void failDownload(String errorMsg, boolean needRetry) {
|
||||
ALog.e(TAG, errorMsg);
|
||||
private void failDownload(BaseException e, boolean needRetry) {
|
||||
if (onFileInfoCallback != null) {
|
||||
onFileInfoCallback.onFail(mEntity.getUrl(), errorMsg, needRetry);
|
||||
onFileInfoCallback.onFail(mEntity.getUrl(), e, needRetry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@ import com.arialyy.aria.core.common.SubThreadConfig;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.DownloadTaskEntity;
|
||||
import com.arialyy.aria.core.inf.IDownloadListener;
|
||||
import com.arialyy.aria.exception.AriaIOException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
@@ -121,11 +123,17 @@ final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEnt
|
||||
handleComplete();
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
fail(mChildCurrentLocation, "下载链接异常", e);
|
||||
fail(mChildCurrentLocation, new TaskException(TAG,
|
||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", mConfig.TEMP_FILE.getName(),
|
||||
mEntity.getDownloadPath(), mEntity.getUrl()), e));
|
||||
} catch (IOException e) {
|
||||
fail(mChildCurrentLocation, String.format("下载失败【%s】", mConfig.URL), e);
|
||||
fail(mChildCurrentLocation, new TaskException(TAG,
|
||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", mConfig.TEMP_FILE.getName(),
|
||||
mEntity.getDownloadPath(), mEntity.getUrl()), e));
|
||||
} catch (Exception e) {
|
||||
fail(mChildCurrentLocation, "获取流失败", e);
|
||||
fail(mChildCurrentLocation, new TaskException(TAG,
|
||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", mConfig.TEMP_FILE.getName(),
|
||||
mEntity.getDownloadPath(), mEntity.getUrl()), e));
|
||||
} finally {
|
||||
try {
|
||||
if (file != null) {
|
||||
@@ -182,7 +190,9 @@ final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEnt
|
||||
}
|
||||
handleComplete();
|
||||
} catch (IOException e) {
|
||||
fail(mChildCurrentLocation, String.format("下载失败【%s】", mConfig.URL), e);
|
||||
fail(mChildCurrentLocation, new AriaIOException(TAG,
|
||||
String.format("文件下载失败,savePath: %s, url: %s", mEntity.getDownloadPath(), mConfig.URL),
|
||||
e));
|
||||
} finally {
|
||||
try {
|
||||
if (fos != null) {
|
||||
@@ -249,9 +259,9 @@ final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEnt
|
||||
if (isBlock) {
|
||||
boolean success = mergeFile();
|
||||
if (!success) {
|
||||
ALog.e(TAG, String.format("任务【%s】分块文件合并失败", mConfig.TEMP_FILE.getName()));
|
||||
STATE.isRunning = false;
|
||||
mListener.onFail(false);
|
||||
mListener.onFail(false, new TaskException(TAG,
|
||||
String.format("任务【%s】分块文件合并失败", mConfig.TEMP_FILE.getName())));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -261,7 +271,10 @@ final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEnt
|
||||
}
|
||||
if (STATE.isFail()) {
|
||||
STATE.isRunning = false;
|
||||
mListener.onFail(false);
|
||||
mListener.onFail(false,
|
||||
new TaskException(TAG,
|
||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", mConfig.TEMP_FILE.getName(),
|
||||
mEntity.getDownloadPath(), mEntity.getUrl())));
|
||||
}
|
||||
} else {
|
||||
ALog.i(TAG, "任务下载完成");
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.arialyy.aria.core.download.downloader;
|
||||
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.inf.IDownloadListener;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
|
||||
/**
|
||||
* Created by Aria.Lao on 2017/7/20.
|
||||
@@ -54,7 +55,7 @@ public interface IDownloadGroupListener extends IDownloadListener {
|
||||
/**
|
||||
* 子任务下载失败
|
||||
*/
|
||||
void onSubFail(DownloadEntity subEntity);
|
||||
void onSubFail(DownloadEntity subEntity, BaseException e);
|
||||
|
||||
/**
|
||||
* 子任务取消下载
|
||||
|
||||
@@ -23,7 +23,8 @@ import com.arialyy.aria.core.download.DownloadTaskEntity;
|
||||
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||
import com.arialyy.aria.core.inf.IDownloadListener;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.util.ErrorHelp;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
|
||||
/**
|
||||
* Created by lyy on 2015/8/25.
|
||||
@@ -91,12 +92,11 @@ public class SimpleDownloadUtil implements IUtil, Runnable {
|
||||
mDownloader.setMaxSpeed(speed);
|
||||
}
|
||||
|
||||
private void failDownload(String msg, boolean needRetry) {
|
||||
private void failDownload(BaseException e, boolean needRetry) {
|
||||
if (isStop || isCancel) {
|
||||
return;
|
||||
}
|
||||
mListener.onFail(needRetry);
|
||||
ErrorHelp.saveError(TAG, msg, "");
|
||||
mListener.onFail(needRetry, e);
|
||||
}
|
||||
|
||||
@Override public void run() {
|
||||
@@ -125,8 +125,8 @@ public class SimpleDownloadUtil implements IUtil, Runnable {
|
||||
mDownloader.start();
|
||||
}
|
||||
|
||||
@Override public void onFail(String url, String errorMsg, boolean needRetry) {
|
||||
failDownload(errorMsg, needRetry);
|
||||
@Override public void onFail(String url, BaseException e, boolean needRetry) {
|
||||
failDownload(e, needRetry);
|
||||
}
|
||||
});
|
||||
case AbsTaskEntity.D_HTTP:
|
||||
@@ -135,8 +135,8 @@ public class SimpleDownloadUtil implements IUtil, Runnable {
|
||||
mDownloader.start();
|
||||
}
|
||||
|
||||
@Override public void onFail(String url, String errorMsg, boolean needRetry) {
|
||||
failDownload(errorMsg, needRetry);
|
||||
@Override public void onFail(String url, BaseException e, boolean needRetry) {
|
||||
failDownload(e, needRetry);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,11 +19,12 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import com.arialyy.aria.orm.DbEntity;
|
||||
import com.arialyy.aria.orm.annotation.Ignore;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by AriaL on 2017/6/29.
|
||||
*/
|
||||
public abstract class AbsEntity extends DbEntity implements IEntity, Parcelable {
|
||||
public abstract class AbsEntity extends DbEntity implements IEntity, Parcelable, Serializable {
|
||||
/**
|
||||
* 速度
|
||||
*/
|
||||
|
||||
@@ -17,15 +17,20 @@ package com.arialyy.aria.core.inf;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.common.IUtil;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by AriaL on 2017/6/29.
|
||||
*/
|
||||
public abstract class AbsTask<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity>
|
||||
implements ITask<TASK_ENTITY> {
|
||||
public static final String ERROR_INFO_KEY = "ERROR_INFO_KEY";
|
||||
|
||||
/**
|
||||
* 是否需要重试,默认为true
|
||||
*/
|
||||
@@ -36,6 +41,10 @@ public abstract class AbsTask<ENTITY extends AbsEntity, TASK_ENTITY extends AbsT
|
||||
boolean isHeighestTask = false;
|
||||
private boolean isCancel = false, isStop = false;
|
||||
protected IUtil mUtil;
|
||||
/**
|
||||
* 扩展信息
|
||||
*/
|
||||
private Map<String, Object> mExpand = new HashMap<>();
|
||||
/**
|
||||
* 该任务的调度类型
|
||||
*/
|
||||
@@ -53,6 +62,28 @@ public abstract class AbsTask<ENTITY extends AbsEntity, TASK_ENTITY extends AbsT
|
||||
return mOutHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加扩展数据
|
||||
* 读取扩展数据{@link #getExpand(String)}
|
||||
*/
|
||||
public void putExpand(String key, Object obj) {
|
||||
if (TextUtils.isEmpty(key)) {
|
||||
ALog.e(TAG, "key 为空");
|
||||
return;
|
||||
} else if (obj == null) {
|
||||
ALog.e(TAG, "扩展数据为空");
|
||||
return;
|
||||
}
|
||||
mExpand.put(key, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取扩展数据
|
||||
*/
|
||||
public Object getExpand(String key) {
|
||||
return mExpand.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最大下载/上传速度
|
||||
*
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.inf;
|
||||
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
|
||||
/**
|
||||
* Created by Aria.Lao on 2017/7/18.
|
||||
* 基础事件
|
||||
@@ -58,8 +60,9 @@ public interface IEventListener {
|
||||
|
||||
/**
|
||||
* 下载失败
|
||||
*
|
||||
* @param needRetry 是否需要重试{@code true} 需要
|
||||
* @param e 失败信息
|
||||
*/
|
||||
void onFail(boolean needRetry);
|
||||
|
||||
void onFail(boolean needRetry, BaseException e);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,10 @@ public class AbsSchedulerListener<TASK extends ITask, SUB_ENTITY extends AbsNorm
|
||||
|
||||
}
|
||||
|
||||
@Override public void onTaskFail(TASK task, Exception e) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void onTaskComplete(TASK task) {
|
||||
|
||||
}
|
||||
@@ -92,10 +96,15 @@ public class AbsSchedulerListener<TASK extends ITask, SUB_ENTITY extends AbsNorm
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onSubTaskFail(TASK task, SUB_ENTITY subTask) {
|
||||
|
||||
}
|
||||
|
||||
public void onSubTaskFail(TASK task, SUB_ENTITY subTask, Exception e) {
|
||||
|
||||
}
|
||||
|
||||
public void onSubTaskRunning(TASK task, SUB_ENTITY subTask) {
|
||||
|
||||
}
|
||||
|
||||
@@ -140,7 +140,8 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
|
||||
listener.onSubTaskStop((TASK) params.groupTask, params.entity);
|
||||
break;
|
||||
case SUB_FAIL:
|
||||
listener.onSubTaskFail((TASK) params.groupTask, params.entity);
|
||||
listener.onSubTaskFail((TASK) params.groupTask, params.entity,
|
||||
(Exception) (params.groupTask).getExpand(AbsTask.ERROR_INFO_KEY));
|
||||
break;
|
||||
case SUB_RUNNING:
|
||||
listener.onSubTaskRunning((TASK) params.groupTask, params.entity);
|
||||
@@ -244,7 +245,7 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
|
||||
listener.onTaskComplete(task);
|
||||
break;
|
||||
case FAIL:
|
||||
listener.onTaskFail(task);
|
||||
listener.onTaskFail(task, (Exception) task.getExpand(AbsTask.ERROR_INFO_KEY));
|
||||
break;
|
||||
case SUPPORT_BREAK_POINT:
|
||||
listener.onNoSupportBreakPoint(task);
|
||||
@@ -317,7 +318,7 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
|
||||
* 启动下一个任务,条件:任务停止,取消下载,任务完成
|
||||
*/
|
||||
private void startNextTask(TASK oldTask) {
|
||||
if (oldTask.getSchedulerType() == TaskSchedulerType.TYPE_STOP_NOT_NEXT){
|
||||
if (oldTask.getSchedulerType() == TaskSchedulerType.TYPE_STOP_NOT_NEXT) {
|
||||
return;
|
||||
}
|
||||
TASK newTask = mQueue.getNextTask();
|
||||
|
||||
@@ -59,10 +59,18 @@ public interface ISchedulerListener<TASK extends ITask> {
|
||||
void onTaskCancel(TASK task);
|
||||
|
||||
/**
|
||||
* 任务下载失败
|
||||
* 任务失败
|
||||
*
|
||||
* @deprecated @see{{@link #onTaskFail(ITask, Exception)}}
|
||||
*/
|
||||
@Deprecated
|
||||
void onTaskFail(TASK task);
|
||||
|
||||
/**
|
||||
* 任务失败
|
||||
*/
|
||||
void onTaskFail(TASK task, Exception e);
|
||||
|
||||
/**
|
||||
* 任务完成
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.arialyy.aria.core.upload;
|
||||
|
||||
import com.arialyy.aria.core.inf.IUploadListener;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
|
||||
/**
|
||||
* Created by lyy on 2017/2/23.
|
||||
@@ -49,7 +50,7 @@ class UploadListener implements IUploadListener {
|
||||
|
||||
}
|
||||
|
||||
@Override public void onFail(boolean needRetry) {
|
||||
@Override public void onFail(boolean needRetry, BaseException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import com.arialyy.aria.core.common.ftp.AbsFtpThreadTask;
|
||||
import com.arialyy.aria.core.inf.IEventListener;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.core.upload.UploadTaskEntity;
|
||||
import com.arialyy.aria.exception.AriaIOException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
||||
import java.io.IOException;
|
||||
@@ -70,7 +72,10 @@ class FtpThreadTask extends AbsFtpThreadTask<UploadEntity, UploadTaskEntity> {
|
||||
client.setRestartOffset(mConfig.START_LOCATION);
|
||||
int reply = client.getReplyCode();
|
||||
if (!FTPReply.isPositivePreliminary(reply) && reply != FTPReply.FILE_ACTION_OK) {
|
||||
fail(mChildCurrentLocation, "上传失败,错误码为:" + reply + ",msg:" + client.getReplyString(), null);
|
||||
fail(mChildCurrentLocation,
|
||||
new AriaIOException(TAG,
|
||||
String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", reply,
|
||||
client.getReplyString(), mEntity.getFilePath())));
|
||||
client.disconnect();
|
||||
return this;
|
||||
}
|
||||
@@ -95,12 +100,14 @@ class FtpThreadTask extends AbsFtpThreadTask<UploadEntity, UploadTaskEntity> {
|
||||
}
|
||||
if (STATE.isFail()) {
|
||||
STATE.isRunning = false;
|
||||
mListener.onFail(false);
|
||||
mListener.onFail(false, new TaskException(TAG,
|
||||
String.format("上传失败,filePath: %s, uploadUrl: %s", mEntity.getFilePath(), mConfig.URL)));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
fail(mChildCurrentLocation, String.format("上传失败【%s】", mConfig.URL), e);
|
||||
fail(mChildCurrentLocation, new AriaIOException(TAG,
|
||||
String.format("上传失败,filePath: %s, uploadUrl: %s", mEntity.getFilePath(), mConfig.URL)));
|
||||
} catch (Exception e) {
|
||||
fail(mChildCurrentLocation, "获取流失败", e);
|
||||
fail(mChildCurrentLocation, new AriaIOException(TAG, null, e));
|
||||
} finally {
|
||||
try {
|
||||
if (file != null) {
|
||||
@@ -128,7 +135,7 @@ class FtpThreadTask extends AbsFtpThreadTask<UploadEntity, UploadTaskEntity> {
|
||||
throws IOException {
|
||||
|
||||
try {
|
||||
ALog.d(TAG, String.format("remotePath【%s】", remotePath));
|
||||
ALog.d(TAG, String.format("remotePath: %s", remotePath));
|
||||
client.storeFile(remotePath, new FtpFISAdapter(bis), new OnFtpInputStreamListener() {
|
||||
boolean isStoped = false;
|
||||
|
||||
@@ -149,10 +156,11 @@ class FtpThreadTask extends AbsFtpThreadTask<UploadEntity, UploadTaskEntity> {
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
if (e.getMessage().contains("IOException caught while copying")) {
|
||||
if (e.getMessage().contains("AriaIOException caught while copying")) {
|
||||
e.printStackTrace();
|
||||
} else {
|
||||
fail(mChildCurrentLocation, "上传失败", e);
|
||||
fail(mChildCurrentLocation,
|
||||
new AriaIOException(TAG, String.format("上传失败,filePath: %s", mEntity.getFilePath()), e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,8 +168,9 @@ class FtpThreadTask extends AbsFtpThreadTask<UploadEntity, UploadTaskEntity> {
|
||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||
if (reply != FTPReply.TRANSFER_ABORTED) {
|
||||
fail(mChildCurrentLocation,
|
||||
String.format("上传文件错误,错误码为:%s,msg:%s", reply, client.getReplyString()),
|
||||
null);
|
||||
new AriaIOException(TAG,
|
||||
String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", reply,
|
||||
client.getReplyString(), mEntity.getFilePath())));
|
||||
}
|
||||
if (client.isConnected()) {
|
||||
client.disconnect();
|
||||
|
||||
@@ -21,6 +21,8 @@ import com.arialyy.aria.core.common.SubThreadConfig;
|
||||
import com.arialyy.aria.core.inf.IUploadListener;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.core.upload.UploadTaskEntity;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@@ -61,8 +63,9 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
|
||||
super.call();
|
||||
File uploadFile = new File(mEntity.getFilePath());
|
||||
if (!uploadFile.exists()) {
|
||||
ALog.e(TAG, String.format("【%s】,文件不存在。", mEntity.getFilePath()));
|
||||
fail();
|
||||
fail(new TaskException(TAG,
|
||||
String.format("上传失败,文件不存在;filePath: %s, url: %s", mEntity.getFilePath(),
|
||||
mEntity.getUrl())));
|
||||
return this;
|
||||
}
|
||||
mListener.onPre();
|
||||
@@ -102,14 +105,15 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
|
||||
mListener.onComplete();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
fail(new TaskException(TAG,
|
||||
String.format("上传失败,filePath: %s, url: %s", mEntity.getFilePath(), mEntity.getUrl()), e));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void fail() {
|
||||
private void fail(BaseException e1) {
|
||||
try {
|
||||
mListener.onFail(true);
|
||||
mListener.onFail(true, e1);
|
||||
STATE.isRunning = false;
|
||||
if (mOutputStream != null) {
|
||||
mOutputStream.close();
|
||||
|
||||
@@ -22,6 +22,8 @@ import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||
import com.arialyy.aria.core.inf.IUploadListener;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.core.upload.UploadTaskEntity;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
import com.arialyy.aria.exception.TaskException;
|
||||
import com.arialyy.aria.util.CheckUtil;
|
||||
|
||||
/**
|
||||
@@ -60,8 +62,8 @@ public class SimpleUploadUtil implements IUtil, Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onFail(String url, String errorMsg, boolean needRetry) {
|
||||
mListener.onFail(needRetry);
|
||||
@Override public void onFail(String url, BaseException e, boolean needRetry) {
|
||||
mListener.onFail(needRetry, e);
|
||||
}
|
||||
}).start();
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.exception;
|
||||
|
||||
public class AriaIOException extends BaseException{
|
||||
private static final String ARIA_NET_EXCEPTION = "Aria Net Exception:";
|
||||
|
||||
public AriaIOException(String tag, String message) {
|
||||
super(tag, String.format("%s%s", ARIA_NET_EXCEPTION, message));
|
||||
}
|
||||
|
||||
public AriaIOException(String tag, String message, Exception e){
|
||||
super(tag, message, e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.exception;
|
||||
|
||||
public abstract class BaseException extends Exception {
|
||||
|
||||
private String tag;
|
||||
|
||||
public BaseException(String tag, String message) {
|
||||
super(message);
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public BaseException(String tag, String message, Exception e) {
|
||||
super(String.format("%s\n%s", message == null ? "" : message, e == null ? "" : e.getMessage()));
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.exception;
|
||||
|
||||
/**
|
||||
* 任务异常
|
||||
*/
|
||||
public class TaskException extends BaseException {
|
||||
private static final String ARIA_TASK_EXCEPTION = "Aria Task Exception:";
|
||||
|
||||
public TaskException(String tag, String detailMessage) {
|
||||
super(tag, String.format("%s, %s", ARIA_TASK_EXCEPTION, detailMessage));
|
||||
}
|
||||
|
||||
public TaskException(String tag, String message, Exception e){
|
||||
super(tag, message, e);
|
||||
}
|
||||
}
|
||||
@@ -222,9 +222,9 @@ public class CheckUtil {
|
||||
} else if (TextUtils.isEmpty(entity.getUrl())) {
|
||||
throw new IllegalArgumentException("下载链接不能为空");
|
||||
} else if (TextUtils.isEmpty(entity.getFileName())) {
|
||||
throw new FileException("文件名不能为null");
|
||||
throw new NullPointerException("文件名不能为null");
|
||||
} else if (TextUtils.isEmpty(entity.getDownloadPath())) {
|
||||
throw new FileException("文件保存路径不能为null");
|
||||
throw new NullPointerException("文件保存路径不能为null");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.arialyy.aria.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.util.Log;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
@@ -38,8 +37,7 @@ public class ErrorHelp {
|
||||
* @param ex 异常
|
||||
*/
|
||||
public static void saveError(String tag, String msg, String ex) {
|
||||
String message = "\nmsg【" + msg + "】\nException:" + ex;
|
||||
writeLogToFile(tag, message);
|
||||
writeLogToFile(tag, String.format("\nmsg【%s】\nException:%s", msg, ex));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,10 +46,8 @@ public class ErrorHelp {
|
||||
* @return "/mnt/sdcard/Android/data/{package_name}/files/log/*"
|
||||
*/
|
||||
private static String getLogPath() {
|
||||
String path = CommonUtil.getAppPath(AriaManager.APP)
|
||||
+ "log/AriaCrash_"
|
||||
+ getData("yyyy-MM-dd_HH:mm:ss")
|
||||
+ ".log";
|
||||
String path = String.format("%slog/AriaCrash_%s.log", CommonUtil.getAppPath(AriaManager.APP),
|
||||
getData("yyyy-MM-dd_HH:mm:ss"));
|
||||
|
||||
File log = new File(path);
|
||||
if (!log.getParentFile().exists()) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.arialyy.compiler;
|
||||
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.annotations.DownloadGroup;
|
||||
import com.arialyy.annotations.Upload;
|
||||
import com.squareup.javapoet.ClassName;
|
||||
import com.squareup.javapoet.CodeBlock;
|
||||
@@ -91,33 +92,54 @@ final class EventProxyFiler {
|
||||
*
|
||||
* @param taskEnum 任务类型枚举{@link TaskEnum}
|
||||
* @param annotation {@link Download}、{@link Upload}
|
||||
* @param methodName 被代理类注解的方法名
|
||||
* @param methodInfo 被代理类注解的方法信息
|
||||
*/
|
||||
private MethodSpec createProxyMethod(TaskEnum taskEnum, Class<? extends Annotation> annotation,
|
||||
String methodName) {
|
||||
MethodInfo methodInfo) {
|
||||
ClassName task = ClassName.get(taskEnum.getPkg(), taskEnum.getClassName());
|
||||
|
||||
ParameterSpec taskParam =
|
||||
ParameterSpec.builder(task, "task").addModifiers(Modifier.FINAL).build();
|
||||
|
||||
String callCode;
|
||||
|
||||
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
|
||||
callCode = "task, subEntity";
|
||||
if (methodInfo.params.get(methodInfo.params.size() - 1)
|
||||
.asType()
|
||||
.toString()
|
||||
.equals(Exception.class.getName())
|
||||
&& annotation == DownloadGroup.onSubTaskFail.class) {
|
||||
callCode = "task, subEntity, e";
|
||||
} else {
|
||||
callCode = "task, subEntity";
|
||||
}
|
||||
} else {
|
||||
callCode = "task";
|
||||
if (methodInfo.params.get(methodInfo.params.size() - 1)
|
||||
.asType()
|
||||
.toString()
|
||||
.equals(Exception.class.getName())
|
||||
&& (annotation == Download.onTaskFail.class
|
||||
|| annotation == Upload.onTaskFail.class
|
||||
|| annotation == DownloadGroup.onTaskFail.class)) {
|
||||
callCode = "task, e";
|
||||
} else {
|
||||
callCode = "task";
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Set<String> keys = keyMapping.get(\"").append(methodName).append("\");\n");
|
||||
sb.append("Set<String> keys = keyMapping.get(\"")
|
||||
.append(methodInfo.methodName)
|
||||
.append("\");\n");
|
||||
sb.append("if (keys != null) {\n\tif (keys.contains(task.getKey())) {\n")
|
||||
.append("\t\tobj.")
|
||||
.append(methodName)
|
||||
.append(methodInfo.methodName)
|
||||
.append("((")
|
||||
.append(taskEnum.getClassName())
|
||||
.append(")")
|
||||
.append(callCode)
|
||||
.append(");\n\t}\n} else {\n")
|
||||
.append("\tobj.")
|
||||
.append(methodName)
|
||||
.append(methodInfo.methodName)
|
||||
.append("((")
|
||||
.append(taskEnum.getClassName())
|
||||
.append(")")
|
||||
@@ -140,6 +162,15 @@ final class EventProxyFiler {
|
||||
|
||||
builder.addParameter(subTaskParam);
|
||||
}
|
||||
|
||||
if (annotation == Download.onTaskFail.class
|
||||
|| annotation == Upload.onTaskFail.class
|
||||
|| annotation == DownloadGroup.onTaskFail.class
|
||||
|| annotation == DownloadGroup.onSubTaskFail.class) {
|
||||
ParameterSpec exception = ParameterSpec.builder(Exception.class, "e").build();
|
||||
builder.addParameter(exception);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -165,7 +196,7 @@ final class EventProxyFiler {
|
||||
//Set<Integer> type = new HashSet<>();
|
||||
//添加注解方法
|
||||
for (TaskEnum te : entity.methods.keySet()) {
|
||||
Map<Class<? extends Annotation>, String> temp = entity.methods.get(te);
|
||||
Map<Class<? extends Annotation>, MethodInfo> methodInfoMap = entity.methods.get(te);
|
||||
//if (entity.proxyClassName.contains(TaskEnum.DOWNLOAD.proxySuffix)) {
|
||||
// type.add(1);
|
||||
//} else if (entity.proxyClassName.contains(TaskEnum.DOWNLOAD_GROUP.proxySuffix)) {
|
||||
@@ -175,9 +206,9 @@ final class EventProxyFiler {
|
||||
//} else if (entity.proxyClassName.contains(TaskEnum.UPLOAD_GROUP.proxySuffix)) {
|
||||
// type.add(4);
|
||||
//}
|
||||
if (temp != null) {
|
||||
for (Class<? extends Annotation> annotation : temp.keySet()) {
|
||||
MethodSpec method = createProxyMethod(te, annotation, temp.get(annotation));
|
||||
if (methodInfoMap != null) {
|
||||
for (Class<? extends Annotation> annotation : methodInfoMap.keySet()) {
|
||||
MethodSpec method = createProxyMethod(te, annotation, methodInfoMap.get(annotation));
|
||||
builder.addMethod(method);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.compiler;
|
||||
|
||||
import java.util.List;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
|
||||
/**
|
||||
* 方法信息
|
||||
*/
|
||||
final class MethodInfo {
|
||||
String methodName;
|
||||
List<VariableElement> params;
|
||||
}
|
||||
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.arialyy.compiler;
|
||||
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.annotations.DownloadGroup;
|
||||
import com.arialyy.annotations.Upload;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -70,11 +73,15 @@ class ParamObtainUtil {
|
||||
ExecutableElement method = (ExecutableElement) element;
|
||||
TypeElement classElement = (TypeElement) method.getEnclosingElement();
|
||||
PackageElement packageElement = mElementUtil.getPackageOf(classElement);
|
||||
checkDownloadMethod(taskEnum, method);
|
||||
|
||||
String methodName = method.getSimpleName().toString();
|
||||
String className = method.getEnclosingElement().toString(); //全类名\
|
||||
String key = className + taskEnum.proxySuffix;
|
||||
ProxyClassParam proxyEntity = mMethodParams.get(key);
|
||||
MethodInfo methodInfo = new MethodInfo();
|
||||
methodInfo.methodName = methodName;
|
||||
methodInfo.params = (List<VariableElement>) method.getParameters();
|
||||
checkMethod(taskEnum, method, annotationClazz, methodInfo.params);
|
||||
|
||||
if (proxyEntity == null) {
|
||||
proxyEntity = new ProxyClassParam();
|
||||
@@ -90,9 +97,10 @@ class ParamObtainUtil {
|
||||
}
|
||||
proxyEntity.taskEnums.add(taskEnum);
|
||||
if (proxyEntity.methods.get(taskEnum) == null) {
|
||||
proxyEntity.methods.put(taskEnum, new HashMap<Class<? extends Annotation>, String>());
|
||||
proxyEntity.methods.put(taskEnum, new HashMap<Class<? extends Annotation>, MethodInfo>());
|
||||
}
|
||||
proxyEntity.methods.get(taskEnum).put(annotationClazz, methodName);
|
||||
|
||||
proxyEntity.methods.get(taskEnum).put(annotationClazz, methodInfo);
|
||||
proxyEntity.keyMappings.put(methodName, getValues(taskEnum, method, annotationType));
|
||||
}
|
||||
}
|
||||
@@ -144,52 +152,71 @@ class ParamObtainUtil {
|
||||
/**
|
||||
* 检查和下载相关的方法,如果被注解的方法为private或参数不合法,则抛异常
|
||||
*/
|
||||
private void checkDownloadMethod(TaskEnum taskEnum, ExecutableElement method) {
|
||||
private void checkMethod(TaskEnum taskEnum, ExecutableElement method,
|
||||
Class<? extends Annotation> annotationClazz, List<VariableElement> params) {
|
||||
String methodName = method.getSimpleName().toString();
|
||||
String className = method.getEnclosingElement().toString();
|
||||
Set<Modifier> modifiers = method.getModifiers();
|
||||
if (modifiers.contains(Modifier.PRIVATE)) {
|
||||
throw new IllegalAccessError(className + "." + methodName + "不能为private方法");
|
||||
throw new IllegalAccessError(String.format("%s.%s, 不能为private方法", className, methodName));
|
||||
}
|
||||
List<VariableElement> params = (List<VariableElement>) method.getParameters();
|
||||
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
|
||||
if (params.size() != 2) {
|
||||
throw new IllegalArgumentException(className
|
||||
+ "."
|
||||
+ methodName
|
||||
+ "参数错误, 参数只有两个,且第一个参数必须是"
|
||||
+ getCheckParams(taskEnum)
|
||||
+ ",第二个参数必须是"
|
||||
+ getCheckSubParams(taskEnum));
|
||||
if (isFailAnnotation(annotationClazz)) {
|
||||
if (params.size() != 3 && params.size() != 2) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("%s.%s参数错误, 参数只能是两个或三个,第一个参数是:%s,第二个参数是:%s,第三个参数(可选)是:%s", className,
|
||||
methodName,
|
||||
getCheckParams(taskEnum), getCheckSubParams(taskEnum),
|
||||
Exception.class.getSimpleName()));
|
||||
}
|
||||
} else {
|
||||
if (params.size() != 2) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("%s.%s参数错误, 参数只能是两个,第一个参数是:%s,第二个参数是:%s", className, methodName,
|
||||
getCheckParams(taskEnum), getCheckSubParams(taskEnum)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (params.size() != 1) {
|
||||
throw new IllegalArgumentException(
|
||||
className + "." + methodName + "参数错误, 参数只能有一个,且参数必须是" + getCheckParams(taskEnum));
|
||||
if (isFailAnnotation(annotationClazz)) {
|
||||
if (params.size() != 1 && params.size() != 2) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("%s.%s参数错误, 参数只能有一个或两个,第一个参数是:%s,第二个参(可选)数是:%s", className, methodName,
|
||||
getCheckParams(taskEnum), Exception.class.getSimpleName()));
|
||||
}
|
||||
} else {
|
||||
if (params.size() != 1) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("%s.%s参数错误, 参数只能有一个,且参数必须是:%s", className, methodName,
|
||||
getCheckParams(taskEnum)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!params.get(0).asType().toString().equals(getCheckParams(taskEnum))) {
|
||||
throw new IllegalArgumentException(className
|
||||
+ "."
|
||||
+ methodName
|
||||
+ "参数【"
|
||||
+ params.get(0).getSimpleName()
|
||||
+ "】类型错误,参数必须是"
|
||||
+ getCheckParams(taskEnum));
|
||||
throw new IllegalArgumentException(
|
||||
String.format("%s.%s参数【%s】类型错误,参数必须是:%s", className, methodName,
|
||||
params.get(0).getSimpleName(), getCheckParams(taskEnum)));
|
||||
}
|
||||
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
|
||||
if (!params.get(1).asType().toString().equals(getCheckSubParams(taskEnum))) {
|
||||
throw new IllegalArgumentException(className
|
||||
+ "."
|
||||
+ methodName
|
||||
+ "参数【"
|
||||
+ params.get(0).getSimpleName()
|
||||
+ "】类型错误,参数必须是"
|
||||
+ getCheckSubParams(taskEnum));
|
||||
throw new IllegalArgumentException(
|
||||
String.format("%s.%s参数【%s】类型错误,参数必须是:%s", className, methodName,
|
||||
params.get(0).getSimpleName(), getCheckSubParams(taskEnum)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是任务失败的回调注解
|
||||
*
|
||||
* @return {@code true}是任务失败的回调注解
|
||||
*/
|
||||
private boolean isFailAnnotation(Class<? extends Annotation> annotationClazz) {
|
||||
return annotationClazz == Download.onTaskFail.class
|
||||
|| annotationClazz == DownloadGroup.onTaskFail.class
|
||||
|| annotationClazz == DownloadGroup.onSubTaskFail.class
|
||||
|| annotationClazz == Upload.onTaskFail.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串数组转set
|
||||
*
|
||||
|
||||
@@ -48,5 +48,5 @@ class ProxyClassParam {
|
||||
|
||||
Set<TaskEnum> taskEnums;
|
||||
Map<String, Set<String>> keyMappings = new HashMap<>();
|
||||
Map<TaskEnum, Map<Class<? extends Annotation>, String>> methods = new HashMap<>();
|
||||
Map<TaskEnum, Map<Class<? extends Annotation>, MethodInfo>> methods = new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
## 开发日志
|
||||
+ v_3.5.2
|
||||
- 添加Serializable接口支持 https://github.com/AriaLyy/Aria/issues/320
|
||||
- 失败回调增加错误原因 https://github.com/AriaLyy/Aria/issues/310
|
||||
```
|
||||
@Download.onTaskFail void taskFail(DownloadTask task, Exception e) {
|
||||
e.getMessage();
|
||||
...
|
||||
}
|
||||
```
|
||||
+ v_3.5.1
|
||||
- 优化`taskExists`方法
|
||||
- 添加`post`参数请求支持
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.arialyy.simple">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
@@ -12,14 +13,16 @@
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<!--android:name=".test.TestFTPDirActivity"-->
|
||||
<!--android:name=".test.AnyRunActivity"-->
|
||||
<!--android:name=".test.TestFTPActivity"-->
|
||||
<!--android:name=".download.group.DownloadGroupActivity"-->
|
||||
<!--android:name=".download.SingleTaskActivity"-->
|
||||
<!--android:name=".MainActivity"-->
|
||||
<!--android:name=".test.AnyRunActivity"-->
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:name=".download.SingleTaskActivity"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
@@ -29,7 +32,7 @@
|
||||
</activity>
|
||||
|
||||
<activity android:name=".download.DownloadActivity"/>
|
||||
<activity android:name=".download.SingleTaskActivity"/>
|
||||
<!--<activity android:name=".download.SingleTaskActivity"/>-->
|
||||
<activity android:name=".download.multi_download.MultiTaskActivity"/>
|
||||
<activity android:name=".download.fragment_download.FragmentActivity"/>
|
||||
<activity android:name=".download.multi_download.MultiDownloadActivity"/>
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
package com.arialyy.simple.download
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import com.arialyy.annotations.Download
|
||||
import com.arialyy.aria.core.Aria
|
||||
import com.arialyy.aria.core.download.DownloadTask
|
||||
import com.arialyy.simple.R
|
||||
import com.arialyy.simple.base.BaseActivity
|
||||
|
||||
/**
|
||||
* Created by lyy on 2017/10/23.
|
||||
*/
|
||||
class KotlinDownloadActivity : AppCompatActivity() {
|
||||
|
||||
private val DOWNLOAD_URL = "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk"
|
||||
|
||||
private val TAG = "KotlinDownloadActivity";
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(setLayoutId())
|
||||
}
|
||||
|
||||
fun setLayoutId(): Int {
|
||||
return R.layout.activity_single
|
||||
}
|
||||
|
||||
fun init(savedInstanceState: Bundle?) {
|
||||
title = "单任务下载"
|
||||
// val target = Aria.download(this).load(DOWNLOAD_URL)
|
||||
// binding.progress = target.getPercent()
|
||||
// if (target.getTaskState() == IEntity.STATE_STOP) {
|
||||
// mStart.setText("恢复")
|
||||
// mStart.setTextColor(resources.getColor(android.R.color.holo_blue_light))
|
||||
// setBtState(true)
|
||||
// } else if (target.isDownloading()) {
|
||||
// setBtState(false)
|
||||
//package com.arialyy.simple.download
|
||||
//
|
||||
//import android.os.Bundle
|
||||
//import android.os.Environment
|
||||
//import android.support.v7.app.AppCompatActivity
|
||||
//import android.util.Log
|
||||
//import android.view.View
|
||||
//import com.arialyy.annotations.Download
|
||||
//import com.arialyy.aria.core.Aria
|
||||
//import com.arialyy.aria.core.download.DownloadTask
|
||||
//import com.arialyy.simple.R
|
||||
//import com.arialyy.simple.base.BaseActivity
|
||||
//
|
||||
///**
|
||||
// * Created by lyy on 2017/10/23.
|
||||
// */
|
||||
//class KotlinDownloadActivity : AppCompatActivity() {
|
||||
//
|
||||
// private val DOWNLOAD_URL = "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk"
|
||||
//
|
||||
// private val TAG = "KotlinDownloadActivity";
|
||||
//
|
||||
// override fun onCreate(savedInstanceState: Bundle?) {
|
||||
// super.onCreate(savedInstanceState)
|
||||
// setContentView(setLayoutId())
|
||||
// }
|
||||
//
|
||||
// fun setLayoutId(): Int {
|
||||
// return R.layout.activity_single
|
||||
// }
|
||||
//
|
||||
// fun init(savedInstanceState: Bundle?) {
|
||||
// title = "单任务下载"
|
||||
//// val target = Aria.download(this).load(DOWNLOAD_URL)
|
||||
//// binding.progress = target.getPercent()
|
||||
//// if (target.getTaskState() == IEntity.STATE_STOP) {
|
||||
//// mStart.setText("恢复")
|
||||
//// mStart.setTextColor(resources.getColor(android.R.color.holo_blue_light))
|
||||
//// setBtState(true)
|
||||
//// } else if (target.isDownloading()) {
|
||||
//// setBtState(false)
|
||||
//// }
|
||||
//// binding.fileSize = target.getConvertFileSize()
|
||||
// Aria.get(this).downloadConfig.maxTaskNum = 2
|
||||
// Aria.download(this).register()
|
||||
// }
|
||||
//
|
||||
// @Download.onTaskRunning
|
||||
// protected fun running(task: DownloadTask) {
|
||||
// Log.d(TAG, task.percent.toString() + "")
|
||||
//// val len = task.fileSize
|
||||
//// if (len == 0L) {
|
||||
//// binding.progress = 0
|
||||
//// } else {
|
||||
//// binding.progress = task.percent
|
||||
//// }
|
||||
//// binding.speed = task.convertSpeed
|
||||
// }
|
||||
//
|
||||
// fun onClick(view: View) {
|
||||
// when (view.id) {
|
||||
// R.id.start -> startD()
|
||||
// R.id.stop -> Aria.download(this).load(DOWNLOAD_URL).stop()
|
||||
// R.id.cancel -> Aria.download(this).load(DOWNLOAD_URL).cancel()
|
||||
// }
|
||||
// binding.fileSize = target.getConvertFileSize()
|
||||
Aria.get(this).downloadConfig.maxTaskNum = 2
|
||||
Aria.download(this).register()
|
||||
}
|
||||
|
||||
@Download.onTaskRunning
|
||||
protected fun running(task: DownloadTask) {
|
||||
Log.d(TAG, task.percent.toString() + "")
|
||||
// val len = task.fileSize
|
||||
// if (len == 0L) {
|
||||
// binding.progress = 0
|
||||
// } else {
|
||||
// binding.progress = task.percent
|
||||
// }
|
||||
// binding.speed = task.convertSpeed
|
||||
}
|
||||
|
||||
fun onClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.start -> startD()
|
||||
R.id.stop -> Aria.download(this).load(DOWNLOAD_URL).stop()
|
||||
R.id.cancel -> Aria.download(this).load(DOWNLOAD_URL).cancel()
|
||||
}
|
||||
}
|
||||
|
||||
private fun startD() {
|
||||
Aria.download(this)
|
||||
.load(DOWNLOAD_URL)
|
||||
.addHeader("groupName", "value")
|
||||
.setDownloadPath(Environment.getExternalStorageDirectory().path + "/hhhhhhhh.apk")
|
||||
.start()
|
||||
}
|
||||
}
|
||||
// }
|
||||
//
|
||||
// private fun startD() {
|
||||
// Aria.download(this)
|
||||
// .load(DOWNLOAD_URL)
|
||||
// .addHeader("groupName", "value")
|
||||
// .setDownloadPath(Environment.getExternalStorageDirectory().path + "/hhhhhhhh.apk")
|
||||
// .start()
|
||||
// }
|
||||
//}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.arialyy.simple.download;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -49,7 +50,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
private static final String DOWNLOAD_URL =
|
||||
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
|
||||
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
|
||||
"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
|
||||
"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apks";
|
||||
//"https://yizi-kejian.oss-cn-beijing.aliyuncs.com/qimeng/package1/qmtable11.zip";
|
||||
//"http://rs.0.gaoshouyou.com/d/04/1e/400423a7551e1f3f0eb1812afa1f9b44.apk";
|
||||
//"http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载
|
||||
@@ -248,7 +249,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
private void startD() {
|
||||
//Aria.get(this).setLogLevel(ALog.LOG_CLOSE);
|
||||
//Aria.download(this).load("aaaa.apk");
|
||||
String path = Environment.getExternalStorageDirectory().getPath() + "/ggsg9.apk";
|
||||
String path = Environment.getExternalStorageDirectory().getPath() + "/ggsg10.apk";
|
||||
//File file = new File(path);
|
||||
//if (file.exists()){
|
||||
// file.delete();
|
||||
|
||||
@@ -31,7 +31,8 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
|
||||
//String URL = "ftps://192.168.29.140:990/download/SDK_Demo-release.apk";
|
||||
//String URL = "http://d.quanscreen.com/k/down/resourceDownLoad?resourceId=1994&clientId=A000011106034058176";
|
||||
//String URL = "ftp://z:z@dygod18.com:21211/[电影天堂www.dy2018.com]猩球崛起3:终极之战BD国英双语中英双字.mkv";
|
||||
String URL = "https://app-dl.byfen.com//app//201810//ef0400d637e768e9c630b4d38633ee06.zip";
|
||||
//String URL = "https://app-dl.byfen.com//app//201810//ef0400d637e768e9c630b4d38633ee06.zip";
|
||||
String URL = "ftps://9.9.9.59:990/download/SDK_Demo-release.apk";
|
||||
//private String URL = "https://www.bilibili.com/bangumi/play/ep77693";
|
||||
//private String URL = "http://cn-hbsjz-cmcc-v-03.acgvideo.com/upgcxcode/63/82/5108263/5108263-1-80.flv?expires=1530178500&platform=pc&ssig=vr7gLl0duyqWqSMnIpzaDA&oi=3746029570&nfa=BpfiWF+i4mNW8KzjZFHzBQ==&dynamic=1&hfa=2030547937&hfb=Yjk5ZmZjM2M1YzY4ZjAwYTMzMTIzYmIyNWY4ODJkNWI=&trid=3476be01a9254115b15f8cc7198600fe&nfc=1";
|
||||
|
||||
@@ -52,8 +53,8 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.start:
|
||||
module.start(URL);
|
||||
//module.startFtp(URL);
|
||||
//module.start(URL);
|
||||
module.startFtp(URL);
|
||||
break;
|
||||
case R.id.stop:
|
||||
module.stop(URL);
|
||||
|
||||
@@ -78,10 +78,10 @@ public class AnyRunnModule {
|
||||
.loadFtp(url)
|
||||
.login("lao", "123456")
|
||||
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/Download/")
|
||||
//.asFtps()
|
||||
//.setStorePath("/mnt/sdcard/Download/server.crt")
|
||||
//.setAlias("www.laoyuyu.me")
|
||||
//.setStorePass("123456")
|
||||
.asFtps()
|
||||
.setStorePath("/mnt/sdcard/Download/server.crt")
|
||||
.setAlias("www.laoyuyu.me")
|
||||
.setStorePass("123456")
|
||||
.start();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,14 @@ package com.arialyy.aria.exception;
|
||||
* Created by lyy on 2017/1/18.
|
||||
* Aria 文件异常
|
||||
*/
|
||||
public class FileException extends NullPointerException {
|
||||
private static final String ARIA_FILE_EXCEPTION = "Aria Exception:";
|
||||
public class FileException extends BaseException {
|
||||
private static final String ARIA_FILE_EXCEPTION = "Aria File Exception:";
|
||||
|
||||
public FileException(String detailMessage) {
|
||||
super(ARIA_FILE_EXCEPTION + detailMessage);
|
||||
public FileException(String tag, String detailMessage) {
|
||||
super(tag, String.format("%s%s", ARIA_FILE_EXCEPTION, detailMessage));
|
||||
}
|
||||
|
||||
public FileException(String tag, String message, Exception e){
|
||||
super(tag, message, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
#Wed Dec 07 20:19:22 CST 2016
|
||||
#org.gradle.daemon=true
|
||||
#org.gradle.jvmargs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
|
||||
# gradle proxy https://chaosleong.github.io/2017/02/10/Configuring-Gradle-Proxy/
|
||||
#systemProp.socksProxyHost=127.0.0.1
|
||||
#systemProp.socksProxyPort=60777
|
||||
|
||||
Reference in New Issue
Block a user