Skip to content

Fix output-dir-flat collisions with --rm - #4855

Open
xiaobai0529 wants to merge 1 commit into
meta:devfrom
xiaobai0529:codex/fix-output-dir-flat-collision-rm
Open

xiaobai0529 wants to merge 1 commit into
meta:devfrom
xiaobai0529:codex/fix-output-dir-flat-collision-rm

Conversation

@xiaobai0529

Copy link
Copy Markdown

Summary

When multiple inputs map to the same basename with --output-dir-flat, zstd currently warns only after processing. With --rm, the second output can overwrite the first and both source files are then deleted, while the command exits successfully.

This change detects collisions before processing. If --rm is enabled, the command fails before writing or removing anything. Without --rm, the existing warning and last-output-wins behavior remains.

On Windows, basename comparison now treats / and \ as separators and compares names case-insensitively.

Fixes #4854

Verification

  • Default make -j4 zstd build passed.
  • The new CLI test covers compression and decompression collisions with --rm, the non-destructive control without --rm, and Windows-only case collisions.
  • python3 run.py basic/output_dir_collision.sh basic/output_dir.sh passed both tests.
  • Replacing only programs/fileio.c and programs/fileio.h with the pre-fix versions makes the new test fail, proving the test exercises the fix.
  • git diff --check passed.

Limitations

  • The Windows-only separator and case-folding branches were reviewed and covered by a conditionally executed test, but were not run on a Windows host in this environment.
  • The regression test exercises compression and decompression; other modes share the same collision helper but were not separately tested.

AI assistance

AI tools were used to investigate and help write this change. I reviewed the implementation and ran the local verification above.

@meta-cla

meta-cla Bot commented Oct 21, 2026

Copy link
Copy Markdown

Hi @xiaobai0529!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label Oct 21, 2026
@meta-cla

meta-cla Bot commented Oct 21, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--output-dir-flat with --rm: colliding output names overwrite each other and both sources are deleted (exit 0)

1 participant