From 4a74e457d58006fb5522b755592aa4cbde4525be Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Sun, 5 Feb 2023 17:25:07 +0800 Subject: [PATCH] modify BlockManager.kt --- .../aria/http/download/HttpDBlockInterceptor.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Http/src/main/java/com/arialyy/aria/http/download/HttpDBlockInterceptor.kt b/Http/src/main/java/com/arialyy/aria/http/download/HttpDBlockInterceptor.kt index 83a06004..84753c4f 100644 --- a/Http/src/main/java/com/arialyy/aria/http/download/HttpDBlockInterceptor.kt +++ b/Http/src/main/java/com/arialyy/aria/http/download/HttpDBlockInterceptor.kt @@ -16,6 +16,7 @@ package com.arialyy.aria.http.download import com.arialyy.aria.core.DuaContext +import com.arialyy.aria.core.inf.IBlockManager import com.arialyy.aria.core.task.BlockUtil import com.arialyy.aria.core.task.ITask import com.arialyy.aria.core.task.ITaskInterceptor @@ -23,6 +24,7 @@ import com.arialyy.aria.core.task.TaskChain import com.arialyy.aria.core.task.TaskResp import com.arialyy.aria.orm.entity.TaskRecord import timber.log.Timber +import java.io.File /** * block interceptor @@ -32,9 +34,11 @@ import timber.log.Timber internal class HttpDBlockInterceptor : ITaskInterceptor { private lateinit var task: ITask private lateinit var option: HttpDTaskOption + private lateinit var blockManager: IBlockManager override suspend fun interceptor(chain: TaskChain): TaskResp { task = chain.getTask() + blockManager = chain.blockManager option = task.getTaskOption(HttpDTaskOption::class.java) if (task.taskState.fileSize < 0) { Timber.e("file size < 0") @@ -44,12 +48,10 @@ internal class HttpDBlockInterceptor : ITaskInterceptor { // if task not support resume, don't save record if (task.taskState.fileSize == 0L) { chain.blockManager.setBlockNum(1) - checkBlock() return chain.proceed(chain.getTask()) } val blockNum = checkRecord() chain.blockManager.setBlockNum(blockNum) - checkBlock() return chain.proceed(chain.getTask()) } @@ -77,13 +79,16 @@ internal class HttpDBlockInterceptor : ITaskInterceptor { return taskRecord.blockNum } Timber.d("record existed") + checkBlock(recordWrapper.taskRecord) return recordWrapper.taskRecord.blockNum } - /** + /**ΓΈ * if block already exist, upload progress */ - private fun checkBlock() { - + private fun checkBlock(record: TaskRecord) { + for (br in record.blockList) { + val block = File() + } } } \ No newline at end of file