Skip to content

The only downloader you need. 下载器的集大成者。

feat(http_pack): 添加临时文件清理功能

XiaoYouChR4cd5727e28fc
diff --git a/features/http_pack/task.py b/features/http_pack/task.py
index 69efbf21..2c0f57e5 100644
--- a/features/http_pack/task.py
+++ b/features/http_pack/task.py
@@ -270,6 +270,14 @@ class HttpWorker(Worker):
self.subworkers.append(HttpSubworker(start, start, self.stage.fileSize - 1)) # Http 请求是以 0 开头的
+ def _cleanupRecordFile(self):
+ target = Path(self.stage.resolvePath + ".ghd")
+ try:
+ if target.is_file() or target.is_symlink():
+ target.unlink()
+ except Exception as e:
+ logger.opt(exception=e).error("failed to cleanup temporary file {}", target)
+
async def run(self):
# prepare async components
self.taskGroup = TaskGroup()
@@ -300,6 +308,7 @@ class HttpWorker(Worker):
self.taskGroup.create_task(self.handleSubworker(subworker))
self.stage.setStatus(TaskStatus.COMPLETED)
+ self._cleanupRecordFile()
logger.info(f"{self.stage.resolvePath} 下载完成")
except CancelledError:
self.stage.setStatus(TaskStatus.PAUSED)