Skip to content

Conversation

@vxtls
Copy link
Contributor

@vxtls vxtls commented Nov 16, 2025

  • Fix Init() method to allow automatic session token retrieval from cookie
  • Change SessionToken from required to optional in configuration
  • Add proper gzip decompression support for API responses
  • Improve error handling for session token acquisition failures
  • Update help text to clarify authentication requirements

Resolves initialization failure and JSON parsing errors when session token can be automatically obtained from browser cookie.

Description / 描述

修复MediaFire驱动中的死代码问题:

  • 修复Init()方法中的逻辑错误,使自动session token获取功能能够正常工作
  • 移除了session token的强制要求,启用了原本存在的自动获取逻辑
  • 修复API响应的gzip解析问题
  • 简化用户配置,现在只需要提供cookie即可

Motivation and Context / 背景

Bug根本原因:

代码中已经实现了从cookie自动获取session token的逻辑(getSessionToken方法),但在Init()方法中,代码首先检查SessionToken是否为空,如果为空就直接返回错误,导致自动获取逻辑永远无法执行。这造成了一个典型的死代码问题
影响:

  • 用户必须手动提供session token,并且session token是会过期的,应该是自动获取,而不是让用户手动填入
  • 自动获取功能完全失效,似乎完全违背设计

解决方案:

  • 调整Init()方法的执行顺序:当SessionToken为空时,先尝试自动获取,获取失败才报错
  • 将SessionToken配置改为可选
  • 同时修复了gzip解析的次要问题

How Has This Been Tested? / 测试

  • 验证仅提供cookie配置时驱动能够成功初始化
  • 确认自动session token获取功能正常工作
  • 测试gzip压缩响应的正确解析
  • 验证原有手动提供session token的功能仍然正常

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

…ip parsing

- Fix Init() method to allow automatic session token retrieval from cookie
- Change SessionToken from required to optional in configuration
- Add proper gzip decompression support for API responses
- Improve error handling for session token acquisition failures
- Update help text to clarify authentication requirements

Resolves initialization failure and JSON parsing errors when session token
can be automatically obtained from browser cookie.
@vxtls
Copy link
Contributor Author

vxtls commented Nov 16, 2025

建议标签:bug, fix, Driver

@ILoveScratch2 ILoveScratch2 added enhancement Module: Driver Driver-Related Issue/PR labels Nov 16, 2025
@vxtls vxtls requested a review from jyxjjj November 16, 2025 04:41
@jyxjjj jyxjjj merged commit e29d92f into OpenListTeam:main Dec 2, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Module: Driver Driver-Related Issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants