facebook / facebook/zstd

Should zstd check archive consistency before overwriting files?

Open
#4,006 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
27.9k
Forks
2.6k
Avg merge
1d 3h
Merged PRs (30d)
8

Description

**Is your feature request related to a problem? Please describe.**
I stumbled upon this when reporting #4005.
The scenario is that corrupt archives can naturally emerge from disks that fill up during compression.
zstd will overwrite files (after prompting the user).
If the decompressed file is corrupt, the user will lose the overwritten file and he will not have obtained any data from the corrupt archive. This could result in potential data loss if the user is inattentive.
Note that while the user is to blame for explicitly allowing overwriting, `zstd` could mitigate this very easily.

**Describe the solution you'd like**
When overwriting files, zstd should check the archive for integrity first (or decompress to a temporary file and move into the existing file when decompression has succeeded).
Along the same lines, decompressing to a temporary would also be beneficial in the scenario where the disk fills up during compression. Then, we could just savely delete the (worthless) temporary without having harmed any other data.

**Describe alternatives you've considered**
zstd could offer to save the decompressed file under a different name. That's how some folder synchronizing software deals with conflicts.

**Additional context**
None.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.