How Unrar Handles Truncated RAR Archives

When a RAR archive is truncated due to an interrupted download, it lacks the complete data stream and expected end-of-archive marker. In response, unrar halts extraction when it encounters the missing data, outputs an "Unexpected end of archive" error, and by default automatically deletes any partially extracted files to avoid leaving corrupted data on your system. However, the exact behavior depends on whether the archive is solid or non-solid, whether recovery data is present, and which command-line flags are applied during extraction.

Error Detection and Termination

During decompression, unrar reads the archive headers and data blocks sequentially. If the file ends prematurely, the utility detects that the actual file size does not match the size defined in the header or that the terminal archive block is missing. It immediately raises an error—most commonly Unexpected end of archive or a CRC failed checksum error—and exits with a non-zero status code.

Default Deletion of Incomplete Files

By default, unrar is designed to prevent corrupted output. If extraction fails halfway through a file due to truncation:

  • The utility aborts processing for that file.
  • It cleans up by deleting the partially written file from your destination directory.
  • Any subsequent files listed in the archive that reside past the truncation point cannot be accessed.

Recovering Data with the Keep Broken Files Flag

To retain partial data from a truncated archive, unrar provides the -kb (Keep Broken extracted files) switch:

unrar x -kb archive.part.rar

When this flag is enabled, unrar bypasses its default cleanup mechanism. If a file is cut off mid-extraction, whatever portion was written to disk prior to hitting the end of the archive will remain intact. This is particularly useful for media files (such as video or audio) that can still be partially played despite missing trailing data.

Solid vs. Non-Solid Archives

The structural format of the archive heavily influences what can be salvaged:

  • Non-Solid Archives: Files compressed earlier in the archive that precede the truncation point can be extracted completely and without errors. Only the specific file spanning the truncation boundary and any files located after it are affected.
  • Solid Archives: Multiple files are treated as a single continuous data stream. While files extracted before the break point may succeed, any interruption in the stream corrupts the decompression dictionary, preventing any subsequent files from being unpacked correctly even if their header metadata is readable.

Multi-Part Archives and Recovery Records

If the truncated file is a segment of a multi-volume set (e.g., .part01.rar), unrar cannot transition to the next volume properly until the current volume is complete. If the archive was created with a built-in recovery record, running rar r archive.rar may restore missing sectors, provided the amount of truncated data does not exceed the size of the recovery record. If recovery data is absent or insufficient, the missing portion must be re-downloaded to complete the extraction.