You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--output-dir-flat with --rm: colliding output names overwrite each other and both sources are deleted (exit 0) #4854
Describe the bug
When two inputs map to the same name in the --output-dir-flat folder, FIO_checkFilenameCollisions()
(programs/fileio.c) only prints a warning, and only at display level 2 or above. zstd then compresses both; the
second output overwrites the first (with -f), --rm removes both sources, and the exit code is 0. The first input
is lost.
On Windows it is worse, because the check itself misses collisions:
it compares names case-sensitively, while the file system is not (d1\a.txt and d2\A.txt produce the same
output file and no warning at all);
it splits paths only on PATH_SEP (\ on Windows), while the output name builder also accepts /, so paths
written with / are compared whole and never collide.
To Reproduce (Windows 11; the first case also applies on any platform)
> mkdir d1 d2 out
> echo first file, d1> d1\x.txt
> echo second file, d2> d2\x.txt
> zstd -f --rm --output-dir-flat out d1\x.txt d2\x.txt
WARNING: Two files have same filename: x.txt
2 files compressed : ...
> echo %errorlevel%
0
> dir /s /b d1 d2 out
...\out\x.txt.zst (contains only "second file, d2"; d1\x.txt and d2\x.txt are gone)
Case-only difference, no warning:
> echo first file, d1> d1\a.txt
> echo second file, d2> d2\A.txt
> zstd -f --rm --output-dir-flat out d1\a.txt d2\A.txt
2 files compressed : ...
> dir /s /b d1 d2 out
...\out\A.txt.zst (contains "second file, d2"; both sources deleted)
Expected behavior
A collision in the flat output folder is an error before anything is written or removed (or at least, --rm is
refused for a run that has collisions), and the exit code is non-zero. On Windows the comparison ignores case and
treats / and \ alike.
Desktop
OS: Windows 11 Pro (26200), x64
Version: v1.5.7; FIO_checkFilenameCollisions() unchanged on dev (2026-10-05)
Compiler: MSVC 14.51 (Visual Studio 2026 Build Tools), Release
Build system: build/cmake, Visual Studio generator
Environment caveats
Found by code review, then reproduced as shown on Windows 11 only (x64), with zstd.exe built from the v1.5.7 source by MSVC 14.51 (Visual Studio 2026 Build Tools) through build/cmake, Win64 Release only. Not tested with MinGW, clang-cl or the official release binaries, nor on Win32.
tests/playTests.sh was not run (no POSIX shell environment here).
The functions cited were compared with dev (2026-10-05) by source and are unchanged, but dev itself was not built.
The analysis was AI-assisted (Claude); every behaviour reported above was reproduced as shown.
Activity