Skip to content

fix(drive): retry and pace Google downloads - #108

Merged
wailbentafat merged 1 commit into
developfrom
fix/drive-download-throttle
Nov 28, 2026
Merged

wailbentafat merged 1 commit into
developfrom
fix/drive-download-throttle

Conversation

@wailbentafat

Copy link
Copy Markdown
Collaborator

Problem

First production import (Markathon, 575 photos) failed after ~650 MB with Google file download failed: Sorry... automated queries. urllib's default User-Agent plus unthrottled bursts got the VPS IP rate-limited. The whole import runs in one transaction, so all progress was lost.

Fix

  • Identify the client with a User-Agent.
  • 0.4s pause between API-key downloads.
  • Retry with backoff (3s, 10s, 30s, 60s, 120s) on 429, 5xx and the HTML block page; other errors (404/403 etc.) fail immediately.

Test

243 unit tests pass, ruff/mypy clean; new tests for the retry classifier, retry-then-succeed and no-retry-on-404.

Not in this PR

The import is still all-or-nothing in one transaction. Resumable per-batch commits would be the next improvement.

A 575-photo import died after ~380 files when Google answered with its
"automated queries" block page, and the single-transaction import lost
all progress. Send a proper User-Agent, pause 0.4s between API-key
downloads, and retry with backoff (3s to 2min) on 429, 5xx and the block
page instead of failing the whole import.
@wailbentafat
wailbentafat merged commit 630bd73 into develop Nov 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant