Repository navigation
Fail on output filename collisions before processing - #4974
Merged
daniellerozenblit merged 2 commits intoNov 18, 2026
Merged
Conversation
With --output-dir-flat, inputs from different directories can map to the same output file. zstd only warned about it, and only after all files were processed, so with -f the earlier outputs were silently overwritten, and with --rm their inputs were deleted too. - Check for collisions before processing any file, and fail the operation if any are found. - For decompression, check the computed output names rather than the input names: different suffixes can map to the same output, e.g. a.tar.zst and a.tzst both decompress to a.tar. - Skip the check with --output-dir-mirror, which keeps outputs in separate directories. - Update the man page, which described the old resolution rules.
Contributor
Author
|
Will add the fix for windows in a separate PR. |
Cyan4973
reviewed
Nov 17, 2026
Cyan4973
left a comment
Contributor
There was a problem hiding this comment.
With --exclude-compressed, files that would be skipped still take part in the collision check: zstd --exclude-compressed --output-dir-flat out d1/x.zst d2/x.zst d1/y now fails without processing anything, while dev compresses d1/y. The check could skip the files that --exclude-compressed excludes.
Files that --exclude-compressed skips don't produce an output, so they can't collide. Leave them out of the --output-dir-flat collision check so that the other files are still processed.
Contributor
Author
|
@Cyan4973 Good catch, thanks! Files skipped by |
Cyan4973
approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
--output-dir-flat, inputs from different directories can map to the same output file issue #4854 Previously, zstd only warned about it, and only after all files were processed, so with -f the earlier outputs were silently overwritten, and with --rm their inputs were deleted too.This PR changes behavior so that we now: