# Understanding the skip_existing_file_size_check Option in you-get

> Learn how to use skip_existing_file_size_check in you-get to avoid re-downloads on unreliable Content-Length headers. Ensure complete downloads efficiently.

- Repository: [Mort Yao/you-get](https://github.com/soimort/you-get)
- Tags: how-to-guide
- Published: 2026-03-06

---

**The `--skip-existing-file-size-check` flag tells you-get to bypass server-reported file size verification, treating any existing local file as complete to prevent unnecessary re-downloads when remote `Content-Length` headers are unreliable.**

The `skip_existing_file_size_check` option in the **you-get** download utility controls whether the tool verifies existing files against server-reported sizes before skipping downloads. When enabled, you-get treats any present file as complete regardless of its actual size, which proves essential when dealing with unreliable CDNs, live streams, or partially downloaded files you wish to preserve.

## How the skip_existing_file_size_check Option Works

According to the source code in `soimort/you-get`, the flag is defined in [`src/you_get/common.py`](https://github.com/soimort/you-get/blob/main/src/you_get/common.py) and influences the download decision logic in the `url_save` function.

### CLI Argument Definition

The option is registered as a boolean flag in the argument parser around line 1585:

```python

# src/you_get/common.py

parser.add_argument(
    '--skip-existing-file-size-check',
    action='store_true',
    default=False,
)

```

### Global Flag and Skip Logic

The flag value is stored as a global variable (line 132) and applied during argument processing (lines 1710-1711). When checking whether to skip an existing file, you-get evaluates the condition at lines 692-696 and 1030-1031:

```python

# src/you_get/common.py – inside url_save()

if not force and (file_size == os.path.getsize(filepath) or skip_existing_file_size_check):
    # Skip the download

```

If `skip_existing_file_size_check` evaluates to **True**, the comparison against `file_size` (the server-reported length) is bypassed entirely. This means the file is considered "already downloaded" even if the local size differs from the remote header. The `--force` flag still overrides this behavior and triggers a re-download when specified.

## When to Use the skip_existing_file_size_check Flag

Several specific scenarios warrant enabling this option to avoid download loops or unwanted overwrites.

### Incorrect Content-Length Headers

Many streaming sites and CDNs return inaccurate `Content-Length` values, particularly for live streams or dynamically generated content. Without the flag, you-get detects a size mismatch and attempts to re-download the file repeatedly. Enabling `--skip-existing-file-size-check` accepts the local file as valid and terminates the operation immediately.

### Preserving Partial Downloads

When downloading large files over unreliable connections, interrupted downloads may leave behind usable partial files. If you want to keep these existing segments rather than restart from scratch, the flag prevents you-get from overwriting them based on size discrepancies.

### Batch Processing Efficiency

In automated scripts that repeatedly process the same URL lists, skipping the size check eliminates network overhead. The tool avoids opening HTTP connections solely to verify file lengths when you already know the content exists locally.

### Testing and Dry Runs

During development or verification workflows where you only need to confirm file existence without validating exact byte counts, this option ensures rapid completion without unnecessary I/O operations.

## Practical Code Examples

These examples demonstrate both CLI and programmatic usage of the option.

### Basic CLI Usage

Skip size verification for a single video download:

```bash
you-get --skip-existing-file-size-check "https://www.example.com/video.mp4"

```

### Overriding with Force

Combine with `--force` to re-download despite the skip flag:

```bash
you-get --skip-existing-file-size-check --force "https://www.example.com/video.mp4"

```

### Programmatic Implementation

When using you-get as a Python library, mirror the CLI behavior by setting the global flag before invoking download functions:

```python
from you_get.common import download_main, download, download_playlist
import argparse

# Simulate CLI argument parsing

parser = argparse.ArgumentParser()
parser.add_argument('--skip-existing-file-size-check', action='store_true')
args = parser.parse_args(['--skip-existing-file-size-check'])

# Apply the flag as the CLI entry point does in src/you_get/__main__.py

if args.skip_existing_file_size_check:
    import you_get.common as yg
    yg.skip_existing_file_size_check = True

# Execute download

download_main(download, download_playlist, ["https://example.com/video.mp4"], False)

```

## Summary

- The `skip_existing_file_size_check` option bypasses the `file_size == os.path.getsize(filepath)` comparison in [`src/you_get/common.py`](https://github.com/soimort/you-get/blob/main/src/you_get/common.py).
- It prevents unnecessary re-downloads when remote servers report incorrect `Content-Length` headers.
- The flag preserves existing files even when their sizes differ from server expectations, while `--force` still enables overwriting.
- Use it for batch scripts, flaky connections, or situations where file existence matters more than exact byte matching.

## Frequently Asked Questions

### Does skip_existing_file_size_check overwrite existing files?

No. When enabled, the option causes you-get to skip downloading entirely if a file exists, regardless of size. To force overwriting, you must use the `--force` flag alongside or instead of the skip option.

### Why does you-get re-download my files even though they look complete?

This typically occurs when the remote server sends an incorrect `Content-Length` header. You-get compares the reported size against your local file, detects a mismatch, and assumes the download is incomplete. Adding `--skip-existing-file-size-check` tells the tool to trust the local file and skip the re-download.

### Can I use this option in Python scripts without the command line?

Yes. As shown in the programmatic example, you can set `you_get.common.skip_existing_file_size_check = True` after parsing arguments. This mimics the behavior of the CLI entry point in [`src/you_get/__main__.py`](https://github.com/soimort/you-get/blob/main/src/you_get/__main__.py) and applies the skip logic to all subsequent download operations.

### Is it safe to always enable skip_existing_file_size_check?

Generally no. Disabling the size check removes the safety net that protects against corrupted or incomplete downloads. Enable this option only when you are confident that existing files are acceptable, such as when dealing with known server header issues or when intentionally preserving partial downloads.