Repository navigation
refactor(download): 重构下载进度跟踪和多线程下载逻辑 - 提取 ProgressTracker 结构体统一管理进度更新,避免重复代码 - 简化多线程下载实现,使用 futures_util 替代手动任务管理 - 改进文件大小探测逻辑,增强 Range 请求处理 - 优化元数据写入函数,提取标签获取逻辑 - #823
Conversation
- 提取 ProgressTracker 结构体统一管理进度更新,避免重复代码 - 简化多线程下载实现,使用 futures_util 替代手动任务管理 - 改进文件大小探测逻辑,增强 Range 请求处理 - 优化元数据写入函数,提取标签获取逻辑
将下载进度回调从 JSON 字符串改为直接传递 NAPI 结构体,提升性能并简化代码 移除 serde 依赖,将进度字段类型从 u64 改为 f64 以兼容 NAPI 改进错误信息,使其更具描述性
This reverts commit cd095c9.
统一进度回调参数处理,支持从Rust返回的snake_case对象和JSON字符串两种格式。移除重复的类型定义,将DownloadProgress接口移至类型声明文件。
Summary of ChangesHello @kazukokawagawa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求主要对下载模块进行了全面的重构和优化。核心目标是提升下载进度跟踪的准确性、多线程下载的效率和稳定性,以及文件元数据写入的健壮性。通过引入新的进度跟踪机制、简化并发下载模型和增强文件信息探测,整体下载体验和代码质量得到了显著改善。 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
| if tagged_file.primary_tag_mut().is_some() { | ||
| return Ok(tagged_file.primary_tag_mut().unwrap()); | ||
| } | ||
|
|
||
| if tagged_file.first_tag_mut().is_some() { | ||
| return Ok(tagged_file.first_tag_mut().unwrap()); | ||
| } |
There was a problem hiding this comment.
这个函数可以通过使用 if let 来变得更高效和符合 Rust 的惯用写法。当前实现中,primary_tag_mut() 和 first_tag_mut() 都被调用了两次(一次用于 is_some() 检查,一次用于 unwrap()),这有些冗余。使用 if let 可以将两次调用合并为一次,使代码更简洁。
| if tagged_file.primary_tag_mut().is_some() { | |
| return Ok(tagged_file.primary_tag_mut().unwrap()); | |
| } | |
| if tagged_file.first_tag_mut().is_some() { | |
| return Ok(tagged_file.first_tag_mut().unwrap()); | |
| } | |
| if let Some(tag) = tagged_file.primary_tag_mut() { | |
| return Ok(tag); | |
| } | |
| if let Some(tag) = tagged_file.first_tag_mut() { | |
| return Ok(tag); | |
| } |
There was a problem hiding this comment.
傻逼这玩意改了就炸了你知道吗
- 新增下载设置选项:启用HTTPS升级和HTTP/2下载 - 升级reqwest到0.13.1并使用rustls-native-certs特性 - 自动将HTTP链接升级为HTTPS以支持HTTP/2协议 - 在下载配置中新增enableDownloadHttps和enableDownloadHttp2参数 - 更新所有相关调用链以传递新的下载参数
- 将 Rust 原生下载器从函数式 API 重构为面向对象的 DownloadTask 类 - 移除独立的 enableDownloadHttps 设置,HTTP/2 启用时自动升级 HTTP 到 HTTPS - 改进下载进度报告机制,优化性能并减少不必要的回调 - 统一下载任务管理,使用 Map 跟踪活动下载以便取消操作 - 清理相关类型定义和配置界面中已移除的选项
No description provided.