|
|
@ -39,8 +39,7 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Created by AriaL on 2017/7/1. |
|
|
|
* Created by AriaL on 2017/7/1. 任务处理器 |
|
|
|
* 任务处理器 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>> |
|
|
|
public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>> |
|
|
|
implements Runnable { |
|
|
|
implements Runnable { |
|
|
@ -299,11 +298,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 检查记录 |
|
|
|
* 检查记录 对于分块任务: 子分块不存在或被删除,子线程将重新下载 对于普通任务: 预下载文件不存在,则任务任务呗删除 |
|
|
|
* 对于分块任务: |
|
|
|
|
|
|
|
* 子分块不存在或被删除,子线程将重新下载 |
|
|
|
|
|
|
|
* 对于普通任务: |
|
|
|
|
|
|
|
* 预下载文件不存在,则任务任务呗删除 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void checkRecord() { |
|
|
|
private void checkRecord() { |
|
|
|
mConfigFile = new File(CommonUtil.getFileConfigPath(false, mEntity.getFileName())); |
|
|
|
mConfigFile = new File(CommonUtil.getFileConfigPath(false, mEntity.getFileName())); |
|
|
@ -421,9 +416,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* convertDb 是兼容性代码 |
|
|
|
* convertDb 是兼容性代码 从3.4.1开始,线程配置信息将存储在数据库中。 将配置文件的内容复制到数据库中,并将配置文件删除 |
|
|
|
* 从3.4.1开始,线程配置信息将存储在数据库中。 |
|
|
|
|
|
|
|
* 将配置文件的内容复制到数据库中,并将配置文件删除 |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void convertDb() { |
|
|
|
private void convertDb() { |
|
|
|
List<RecordWrapper> records = |
|
|
|
List<RecordWrapper> records = |
|
|
@ -667,10 +660,15 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte |
|
|
|
config.END_LOCATION = config.TOTAL_FILE_SIZE; |
|
|
|
config.END_LOCATION = config.TOTAL_FILE_SIZE; |
|
|
|
config.SUPPORT_BP = mTaskEntity.isSupportBP(); |
|
|
|
config.SUPPORT_BP = mTaskEntity.isSupportBP(); |
|
|
|
config.TASK_ENTITY = mTaskEntity; |
|
|
|
config.TASK_ENTITY = mTaskEntity; |
|
|
|
ThreadRecord record = new ThreadRecord(); |
|
|
|
ThreadRecord record = DbEntity.findFirst(ThreadRecord.class, "key=?", mRecord.filePath); |
|
|
|
|
|
|
|
if (record != null) { |
|
|
|
|
|
|
|
record.deleteData(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
record = new ThreadRecord(); |
|
|
|
record.startLocation = 0; |
|
|
|
record.startLocation = 0; |
|
|
|
record.endLocation = config.TOTAL_FILE_SIZE; |
|
|
|
record.endLocation = config.TOTAL_FILE_SIZE; |
|
|
|
record.key = mTempFile.getPath(); |
|
|
|
record.key = mTempFile.getPath(); |
|
|
|
|
|
|
|
mRecord.threadRecords.add(record); |
|
|
|
config.THREAD_RECORD = record; |
|
|
|
config.THREAD_RECORD = record; |
|
|
|
AbsThreadTask task = selectThreadTask(config); |
|
|
|
AbsThreadTask task = selectThreadTask(config); |
|
|
|
if (task == null) return; |
|
|
|
if (task == null) return; |
|
|
|