|
|
|
@ -67,6 +67,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
|
* @param refreshInfo 是否刷新下载信息 |
|
|
|
|
*/ |
|
|
|
|
public DownloadTarget load(DownloadEntity entity, boolean refreshInfo) { |
|
|
|
|
CheckUtil.checkDownloadEntity(entity); |
|
|
|
|
return new DownloadTarget(entity, targetName, refreshInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -86,7 +87,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
|
* @param refreshInfo 是否刷新下载信息 |
|
|
|
|
*/ |
|
|
|
|
public DownloadTarget load(@NonNull String url, boolean refreshInfo) { |
|
|
|
|
CheckUtil.checkDownloadUrl(url); |
|
|
|
|
CheckUtil.checkUrl(url); |
|
|
|
|
return new DownloadTarget(url, targetName, refreshInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -98,6 +99,28 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
|
return new DownloadGroupTarget(urls, targetName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 使用下载实体执行FTP下载操作 |
|
|
|
|
* |
|
|
|
|
* @param entity 下载实体 |
|
|
|
|
*/ |
|
|
|
|
public FtpDownloadTarget loadFtp(DownloadEntity entity) { |
|
|
|
|
return loadFtp(entity, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 使用下载实体执行下载操作 |
|
|
|
|
* |
|
|
|
|
* @param refreshInfo 是否刷新下载信息 |
|
|
|
|
*/ |
|
|
|
|
public FtpDownloadTarget loadFtp(DownloadEntity entity, boolean refreshInfo) { |
|
|
|
|
CheckUtil.checkDownloadEntity(entity); |
|
|
|
|
if (!entity.getUrl().startsWith("ftp")) { |
|
|
|
|
throw new IllegalArgumentException("非FTP请求不能使用该方法"); |
|
|
|
|
} |
|
|
|
|
return new FtpDownloadTarget(entity, targetName, refreshInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 加载ftp单任务下载地址 |
|
|
|
|
*/ |
|
|
|
@ -111,7 +134,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
|
* @param refreshInfo 是否刷新下载信息 |
|
|
|
|
*/ |
|
|
|
|
public FtpDownloadTarget loadFtp(@NonNull String url, boolean refreshInfo) { |
|
|
|
|
CheckUtil.checkDownloadUrl(url); |
|
|
|
|
CheckUtil.checkUrl(url); |
|
|
|
|
return new FtpDownloadTarget(url, targetName, refreshInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -129,7 +152,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
|
* 加载ftp文件夹下载地址 |
|
|
|
|
*/ |
|
|
|
|
public FtpDirDownloadTarget loadFtpDir(@NonNull String dirUrl) { |
|
|
|
|
CheckUtil.checkDownloadUrl(dirUrl); |
|
|
|
|
CheckUtil.checkUrl(dirUrl); |
|
|
|
|
return new FtpDirDownloadTarget(dirUrl, targetName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -180,7 +203,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
|
* 通过下载链接获取下载实体 |
|
|
|
|
*/ |
|
|
|
|
public DownloadEntity getDownloadEntity(String downloadUrl) { |
|
|
|
|
CheckUtil.checkDownloadUrl(downloadUrl); |
|
|
|
|
CheckUtil.checkUrl(downloadUrl); |
|
|
|
|
return DbEntity.findFirst(DownloadEntity.class, "url=? and isGroupChild='false'", downloadUrl); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -188,7 +211,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
|
* 通过下载链接获取保存在数据库的下载任务实体 |
|
|
|
|
*/ |
|
|
|
|
public DownloadTaskEntity getDownloadTask(String downloadUrl) { |
|
|
|
|
CheckUtil.checkDownloadUrl(downloadUrl); |
|
|
|
|
CheckUtil.checkUrl(downloadUrl); |
|
|
|
|
DownloadEntity entity = getDownloadEntity(downloadUrl); |
|
|
|
|
if (entity == null || TextUtils.isEmpty(entity.getDownloadPath())) return null; |
|
|
|
|
return DbEntity.findFirst(DownloadTaskEntity.class, "key=? and isGroupTask='false'", |
|
|
|
|