增加允许不使用apt直接通过实现监听器来回调下载进度更新,该功能由[chenfei0928](https://github.com/chenfei0928)提交,感谢他的pr。如果注解不生效,只需要实现接口便可
修复m3u8任务地址错误时,无法删除实体的问题 https://github.com/AriaLyy/Aria/issues/71://github.com/AriaLyy/Aria/issues/712
This commit is contained in:
@@ -47,7 +47,7 @@ public class DownloadConfig extends BaseTaskConfig implements Serializable {
|
||||
/**
|
||||
* 设置http下载获取文件大小是否使用Head请求。true:使用head请求,false:使用默认的get请求
|
||||
*/
|
||||
boolean useHeadRequest;
|
||||
boolean useHeadRequest = false;
|
||||
|
||||
public boolean isUseHeadRequest() {
|
||||
return useHeadRequest;
|
||||
|
||||
@@ -157,7 +157,7 @@ public class XMLReader extends DefaultHandler {
|
||||
setField("subReTryInterval", subReTryInterval, ConfigType.D_GROUP);
|
||||
break;
|
||||
case "useHeadRequest": // 是否使用head请求
|
||||
boolean useHeadRequest = checkBoolean(value) ? Boolean.valueOf(value) : true;
|
||||
boolean useHeadRequest = checkBoolean(value) ? Boolean.valueOf(value) : false;
|
||||
setField("useHeadRequest", useHeadRequest, ConfigType.DOWNLOAD);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class DbEntity {
|
||||
private static final Object LOCK = new Object();
|
||||
protected long rowID = -1;
|
||||
public long rowID = -1;
|
||||
|
||||
protected DbEntity() {
|
||||
|
||||
|
||||
@@ -768,7 +768,7 @@ public class CommonUtil {
|
||||
field = clazz.getField(name);
|
||||
} catch (NoSuchFieldException e1) {
|
||||
if (clazz.getSuperclass() == null) {
|
||||
return field;
|
||||
return null;
|
||||
} else {
|
||||
field = getField(clazz.getSuperclass(), name);
|
||||
}
|
||||
@@ -780,6 +780,32 @@ public class CommonUtil {
|
||||
return field;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类里面的指定对象,如果该类没有则从父类查询
|
||||
*/
|
||||
public static Method getMethod(Class clazz, String methodName, Class<?>... params){
|
||||
Method method = null;
|
||||
try {
|
||||
method = clazz.getDeclaredMethod(methodName, params);
|
||||
} catch (NoSuchMethodException e) {
|
||||
try {
|
||||
method = clazz.getMethod(methodName, params);
|
||||
} catch (NoSuchMethodException ex) {
|
||||
if (clazz.getSuperclass() == null) {
|
||||
return null;
|
||||
} else {
|
||||
method = getMethod(clazz.getSuperclass(), methodName, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (method != null){
|
||||
method.setAccessible(true);
|
||||
}
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转hashcode
|
||||
*/
|
||||
|
||||
@@ -34,14 +34,14 @@ public class DeleteDGRecord implements IDeleteRecord {
|
||||
|
||||
private static volatile DeleteDGRecord INSTANCE = null;
|
||||
|
||||
private DeleteDGRecord(){
|
||||
private DeleteDGRecord() {
|
||||
|
||||
}
|
||||
|
||||
public static DeleteDGRecord getInstance() {
|
||||
if (INSTANCE == null){
|
||||
synchronized (DeleteDGRecord.class){
|
||||
if (INSTANCE == null){
|
||||
if (INSTANCE == null) {
|
||||
synchronized (DeleteDGRecord.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new DeleteDGRecord();
|
||||
}
|
||||
}
|
||||
@@ -108,9 +108,13 @@ public class DeleteDGRecord implements IDeleteRecord {
|
||||
}
|
||||
}
|
||||
|
||||
deleteEntity(needRemoveEntity, groupEntity.getGroupHash());
|
||||
}
|
||||
|
||||
private void deleteEntity(boolean needRemoveEntity, String groupHash) {
|
||||
if (needRemoveEntity) {
|
||||
DbEntity.deleteData(DownloadEntity.class, "groupHash=?", groupEntity.getGroupHash());
|
||||
DbEntity.deleteData(DownloadGroupEntity.class, "groupHash=?", groupEntity.getGroupHash());
|
||||
DbEntity.deleteData(DownloadEntity.class, "groupHash=?", groupHash);
|
||||
DbEntity.deleteData(DownloadGroupEntity.class, "groupHash=?", groupHash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,9 +92,9 @@ public class DeleteDRecord implements IDeleteRecord {
|
||||
|
||||
TaskRecord record = DbDataHelper.getTaskRecord(entity.getFilePath(), entity.getTaskType());
|
||||
if (record == null) {
|
||||
ALog.e(TAG, "删除下载记录失败,记录为空,filePath:" + entity.getFilePath());
|
||||
ALog.e(TAG, "删除下载记录失败,记录为空,将删除实体记录,filePath:" + entity.getFilePath());
|
||||
FileUtil.deleteFile(targetFile);
|
||||
DbEntity.deleteData(DownloadEntity.class, "downloadPath=?", filePath);
|
||||
deleteEntity(needRemoveEntity, filePath);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -111,6 +111,10 @@ public class DeleteDRecord implements IDeleteRecord {
|
||||
}
|
||||
}
|
||||
|
||||
deleteEntity(needRemoveEntity, filePath);
|
||||
}
|
||||
|
||||
private void deleteEntity(boolean needRemoveEntity, String filePath){
|
||||
if (needRemoveEntity) {
|
||||
DbEntity.deleteData(DownloadEntity.class, "downloadPath=?", filePath);
|
||||
}
|
||||
|
||||
@@ -76,12 +76,13 @@ public class DeleteM3u8Record implements IDeleteRecord {
|
||||
}
|
||||
|
||||
DownloadEntity entity = (DownloadEntity) absEntity;
|
||||
TaskRecord record = DbDataHelper.getTaskRecord(entity.getFilePath(), entity.getTaskType());
|
||||
final String filePath = entity.getFilePath();
|
||||
TaskRecord record = DbDataHelper.getTaskRecord(filePath, entity.getTaskType());
|
||||
if (record == null) {
|
||||
ALog.e(TAG, "删除下载记录失败,记录为空,filePath:" + entity.getFilePath());
|
||||
ALog.e(TAG, "删除下载记录失败,记录为空,将删除实体记录,filePath:" + entity.getFilePath());
|
||||
deleteEntity(needRemoveEntity, filePath);
|
||||
return;
|
||||
}
|
||||
final String filePath = entity.getFilePath();
|
||||
|
||||
// 删除下载的线程记录和任务记录
|
||||
DbEntity.deleteData(ThreadRecord.class, "taskKey=? AND threadType=?", filePath,
|
||||
@@ -95,6 +96,10 @@ public class DeleteM3u8Record implements IDeleteRecord {
|
||||
FileUtil.deleteFile(filePath);
|
||||
}
|
||||
|
||||
deleteEntity(needRemoveEntity, filePath);
|
||||
}
|
||||
|
||||
private void deleteEntity(boolean needRemoveEntity, String filePath){
|
||||
if (needRemoveEntity) {
|
||||
DbEntity.deleteData(DownloadEntity.class, "downloadPath=?", filePath);
|
||||
}
|
||||
|
||||
@@ -88,8 +88,12 @@ public class DeleteURecord implements IDeleteRecord {
|
||||
FileUtil.deleteFile(entity.getFilePath());
|
||||
}
|
||||
|
||||
deleteEntity(needRemoveEntity, entity.getFilePath());
|
||||
}
|
||||
|
||||
private void deleteEntity(boolean needRemoveEntity, String filePath) {
|
||||
if (needRemoveEntity) {
|
||||
DbEntity.deleteData(UploadEntity.class, "filePath=?", entity.getFilePath());
|
||||
DbEntity.deleteData(UploadEntity.class, "filePath=?", filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user