← Back to Pull requests

Send big files in pieces, so a dropped connection doesn't start them again #144

Closed
unknown closed this pull request without merging on Nov 22, 2026 04:37 UTC
View on GitHub
unknown unknown commented on Nov 22, 2026 03:51 UTC
Author

Why

Uploading an 835 MB Evernote export kept going back to zero. Each file went up as one long request. Over the Funnel tunnel, a connection drop came before the end almost every time, and each drop started the whole file again. I couldn't find what causes the drops (nothing documented about Funnel limits long requests), so this makes a drop cheap instead.

What changed

Server

  • PUT /api/uploads/{id} now also takes offset and size. With them, the body is one piece of a file size bytes long, starting at offset.

  • Pieces are written to a hidden .parts/<sha256(path, size, modified)>.piece and moved into place once the last byte is in. Finishing an upload never picks up half a file.

  • A piece is written from its offset, cutting anything an earlier try left past that point. If the file holds less than offset, the piece is refused with a 409.

  • An earlier try at the same file, still waiting on a dead connection, now gives way at once to the newer try. Before, it held the file for 45 seconds.

  • New GET /api/uploads/{id}/piece?path=&size=&modified= says how much of a file has arrived. If the file is already whole and only the answer to its last piece was lost, it answers the full size.

  • Starting an upload of the same files again now also answers partly: [{ path, bytes }]. A page closed partway therefore carries on from where it stopped. A file that has changed since has a different piece name and starts again.

  • Whole-file uploads (no offset) behave exactly as before. The iOS client is unaffected.
  • Page

  • Files over 32 MB go in 32 MB pieces.

  • After a piece goes unanswered, the page asks how much arrived and carries on from there.

  • A piece that goes through resets the give-up clock.

  • What arrived stays on the progress bar instead of dropping back to zero.
  • docs/technical.md is updated.

    Testing

  • 457 .NET tests and 159 web tests pass. New tests cover:

  • - a piece cut off and sent again
    - a last piece whose answer was lost
    - pieces that don't follow on or run past the end
    - picking up after the page went away, including a changed file starting again
    - an earlier try still waiting on its connection giving way
    - the page carrying on from what Uncloud kept
  • On a separate local server:

  • - A 100 MB file dropped onto My files in the browser, with the second piece's connection cut, arrived byte for byte (SHA-256 matched).
    - With curl, a piece was cut off about 9 MB in. Uncloud kept that much. Adding the file again reported it under partly. Sending the rest finished the file, and its SHA-256 matched the original.

    For reviewers

  • The drop cause itself isn't fixed, only made cheap. Each drop now costs at most what was in flight.

  • Per-request overhead is one round trip per 32 MB. That's small next to the transfer time over the tunnel.

  • An upload started before this deploys still sends whole files, until its page is reloaded.
  • 🤖 Generated with Claude Code

    Diff: 374 lines (+280 / -94) across 4 files Reviewer: ethanteng Review duration: 46m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 374 lines diff across 4 files
    0.43
    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%
    56%
    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.355
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #144"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 42.9% (MEDIUM) · Higher = larger blast radius
    42.9%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 18.5% · Safe to merge
    18.5%