← Back to Pull requests

fix(lms): 下载失败或取消时保留另存为的原文件 #111

Closed
unknown closed this pull request without merging on Nov 29, 2026 11:56 UTC
View on GitHub
unknown unknown commented on Nov 27, 2026 06:01 UTC
Author

变更说明

在思源学堂给附件或课程回放点「另存为」,如果选了一个已有文件并确认覆盖,服务器返回 503 时,旧版会报「下载失败」,并删除磁盘上原有的文件。下载途中断网也会丢掉原件。#79 中的取消和清理半成品走这条下载路径。

下载线程现用 Qt 的 QSaveFile 在目标目录暂存数据。完整接收后显式检查最后一次缓冲写入,再检查取消状态,最后才提交替换。写入中断、取消或替换失败时保留原件。

验证

  • 新增六项回归测试,覆盖请求失败、流中断、最后一块写入后取消、缓冲写入失败、缓冲写入期间取消及成功覆盖。

  • 测试纳入 qt-ui 域和历史回归集。

  • 在 Linux、Python 3.13 和 PyQt5 上运行相关测试。

  • 原提交 fcb42d5 的上游矩阵共 33 项检查通过。新的检查按当前提交记录。PR 检查
  • 测试证据

  • 在基线 eb47d32 运行新测试,前三项失败,成功覆盖的对照通过。候选版四项通过。

  • python -m test.ci.run_test_shard --domain qt-ui 全部 211 项通过。python local_test.py 总计运行 515 项,513 项通过、2 项因未提供真实校园账号密码而跳过。python -m test.ci.run_test_regressions 的 240 项也全部通过。python -m test.ci.check_test_contract 通过,5 个测试域覆盖 37 个模块。

  • 实际打开课程回放列表,点「另存为」,在 Qt 文件对话框里选取已有文件并确认覆盖。用本机 HTTP 服务先返回 503,再返回 200。503 时基线删除了已有文件,修复后原内容仍在。200 时界面报告「下载成功」,原文件被完整替换。此次使用测试文件和模拟登录态。
  • 评审后复验

    按 JimmyWang0417 给出的 Linux 用例,将单进程的文件大小限制设为 8 字节后,用 Qt 5.15.18 下载 20 字节。在 fcb42d5 上,通过课程回放的「另存为」选择已有文件并确认覆盖,界面提示「下载成功」,实际只保存了前 8 字节。现在先检查 flush(),失败会走已有的错误和清理路径。提交前仍会检查取消状态。行内复现

  • 相同文件、相同覆盖操作,adcd944 显示「下载失败」,已有文件逐字节保留。解除文件大小限制后,完整的 20 字节正常替换原件。数据通过本机 HTTP 服务提供,校园登录使用模拟会话。

  • 两个新增的跨平台回归分别模拟最后一次缓冲写入失败和写入期间收到取消。在 fcb42d5 上两项都失败。更新后下载测试 6 项全部通过,维护者提供的真实系统限额用例也通过。

  • uv run --frozen python local_test.py 运行 517 项,515 通过,2 项因缺少校园账号跳过,其中 Qt 域 213 项全部通过。独立历史回归 242 项全部通过。
  • 本次复现、代码修改和验证使用了 OpenAI Codex。

    Diff: 184 lines (+138 / -46) across 2 files Reviewer: JimmyWang0417 Review duration: 3235m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 184 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.312
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #111"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 35.7% (MEDIUM) · Higher = larger blast radius
    35.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.1% · Safe to merge
    14.1%