# ✅ Checkpoint: Download Engineering

By Lê Nguyễn Tuân



## Quiz

1. A resumable image download sends `Range: bytes=921600-` but the server responds with status `200` and the full body. What must the downloader do?
   - Truncate the `.part` file and write from byte 0, because the server ignored the range and sent the whole body.
   - Append the body to the existing `.part` file, since the server confirmed the request succeeded.
   - Publish the file with `os.replace` and let the integrity check fix it later.
   - Retry with backoff until the server returns `206 Partial Content`.
2. Which failure should NOT be retried by the image downloader?
   - `429 Too Many Requests` with a `Retry-After` header
   - `503 Service Unavailable`
   - `403 Forbidden`
   - A read timeout mid-transfer
3. In an HLS manifest, which tag declares the initialization segment that must be written before any fMP4 media fragment?
   - `#EXT-X-STREAM-INF`
   - `#EXTINF`
   - `#EXT-X-ENDLIST`
   - `#EXT-X-MAP`
4. A DASH manifest offers 1080p, 720p and 480p video representations plus one audio-only representation. The config sets `max_height: 720`. What should the crawler download?
   - The 720p video representation plus the audio representation, then mux them at merge time.
   - Only the 1080p representation, because highest quality is always safest for archival.
   - The 720p video representation only, since audio is embedded in the video fragments.
   - The 480p representation, because it is the smallest eligible stream.
5. Which statements about the capstone storage contract are correct? Select all that apply.
   - The stored file extension should be taken from the URL path, since platforms always serve the matching format.
   - The final path derives from the content hash, not from the URL, timestamp or post ID.
   - A `200` response with `Content-Type: image/jpeg` is enough proof that the body is a valid JPEG.
   - `tmp_root` and `media_root` should be on the same filesystem so `os.replace` stays atomic.
   - Hashing should happen inside the write loop so each chunk is hashed and written in one pass.
6. Which checks does the storage stage run on a downloaded file before publishing it? Select all that apply.
   - Check the size falls inside the configured min/max bounds for that media kind.
   - Sniff the leading magic bytes against the claimed format.
   - Trust the `Content-Type` header as the authoritative format signal.
   - Derive the stored extension from the sniffed format rather than the URL.
   - Compare bytes written against `Content-Length` when that header exists.
7. A resumable download sends the `Range` request header and expects status code ____ back from a server that honored it.
8. After merging fragments, the capstone validates duration and dimensions of the output video with the ____ tool.
9. In the capstone, in-progress bytes are written to a temp file and published into the store with `os.replace`, which is ____ on the same filesystem.
10. Explain how your capstone download stage guarantees that a killed worker never leaves a corrupt or duplicated file in the store. Cover the temp-file lifecycle, the resume path, and the dedupe moments.


---

## Contents

Part of [🎞️ Media Crawler Architecture: Queue, Storage and Scaling](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling.md)

- **🧭 Foundations and Capstone Skeleton**
  - [🔍 How Facebook, Weibo and Bilibili Serve Media](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/media-serving-anatomy-three-platforms.md)
  - [🧱 Capstone Blueprint: Config, Storage Layout, Pipeline Modules](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/capstone-blueprint-config-storage-pipeline.md) (sign-in required)
  - [🧩 Capstone Step 1: Normalize Media Records from Feed Responses](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/capstone-normalize-media-records.md)
  - [✅ Checkpoint: Platform Anatomy and Project Skeleton](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/checkpoint-platform-anatomy-skeleton.md)
- **📥 Media Download Engineering**
  - [🌊 Streaming Image Downloads: Chunks, Resume, Retries, Timeouts](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/streaming-image-downloads-resume-retries.md)
  - [🎥 Video Downloads: Manifests, Fragments, Resolution Selection](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/video-downloads-manifests-fragments-resolution.md)
  - [🗄️ Capstone Step 2: Storage, Content Hashing and Integrity Checks](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/capstone-storage-hashing-integrity.md)
  - [✅ Checkpoint: Download Engineering](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/checkpoint-download-engineering.md) — this lesson
- **🏗️ Architecture, Scheduling and Scaling**
  - [🔁 Queue-Based Workers: Task Model, Backpressure, Rate Budget](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/queue-workers-task-model-backpressure.md)
  - [🚀 Capstone Step 3: Observability, Recovery and Scaling Out](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/capstone-observability-recovery-scaling.md) (premium content)
  - [✅ Checkpoint: Architecture and Scaling](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/checkpoint-architecture-scaling.md) (premium content)
- [Course cheatsheet](https://everwise.study/courses/media-crawler-architecture-queue-storage-and-scaling/cheatsheet.md) (premium content)
