Repeating the same file operand: `a` fails with "Duplicate filename on disk", `h` counts the file twice, `l/x/t/d` de-duplicate
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 56/100
Research direction
Start with the named paths in CPP/7zip/UI/Common/EnumDirItems.cpp and CPP/Common/Wildcard.cpp, then compare direct-name enumeration with wildcard enumeration. Reproduce with the commands in the issue and inspect how repeated operands reach archive creation and hashing. Done means a archives the repeated file once and h lists it once, consistently with l, x, t and d.
Written by the indexing model from the issue text.
Description
Environment
- 7-Zip (z) 26.06 (arm64),
ip7z/7zip@d3296e3, built withCPP/7zip/cmpl_mac_arm64.mak(Bundles/Alone2) - macOS arm64, Apple clang
Description
Naming the same file twice is fatal for a (rc=2, no archive written) and is double counted by h. Selecting the same file through a wildcard plus a literal (a.txt *.txt) is accepted, and l/x/t/d treat a repeated name as one selector.
Steps to reproduce
Z=7zz
d=$(mktemp -d) && cd "$d" && mkdir w && cd w
echo hi > a.txt
$Z a -bd ../x.7z a.txt a.txt; echo "a a.txt a.txt: rc=$?"; ls ../x.7z
$Z a -bd ../y.7z a.txt '*.txt' >/dev/null; echo "a a.txt '*.txt': rc=$?"
$Z h -bd a.txt a.txt | grep -E '^Files:|a.txt'
$Z a -bd ../k.7z a.txt >/dev/null; $Z l -bd ../k.7z a.txt a.txt | tail -1
Observed (two runs):
ERROR:
Duplicate filename on disk:
a.txt
a.txt
a a.txt a.txt: rc=2
ls: ../x.7z: No such file or directory
a a.txt '*.txt': rc=0
ED6F7A7A 3 a.txt
ED6F7A7A 3 a.txt
Files: 2
2026-11-25 12:18:06 3 7 1 files
Expected
The documentation describes the arguments as a set of file names or wildcards to process and gives no rule that a name may appear only once:
The switches and other filenames can be in any order.
The default wildcard "*" will be used if there is no filename/wildcard in the command line.
(https://7-zip.opensource.jp/chm/cmdline/syntax.htm). Since a a.txt '*.txt' (the same file selected twice) is accepted and l/x/t/d select a.txt once for a.txt a.txt, a a.txt a.txt should produce an archive with one a.txt, and h a.txt a.txt should list it once.
Actual
a: rc=2 with Duplicate filename on disk, no archive. h: two identical lines, Files: 2. l: one item.
Root cause (analysis on d3296e3)
CPP/7zip/UI/Common/EnumDirItems.cpp:813-919: when every include item is a plain name (CanUseFsDirect, line 806), the loop walkscurNode.IncludeItemsand callsdirItems.AddDirFileInfo()(line 919) once per item. Two identical items give two identicalCDirItementries.- The wildcard path (generic enumeration) visits each directory entry once, so overlap through
*.txtnever produces a duplicate entry. CPP/7zip/UI/Common/UpdatePair.cpp:181-187sorts the disk names and throwsk_Duplicate_inDir_Message("Duplicate filename on disk:", line 103) when two neighbours compare equal. That is theafailure.hhas no such check and prints both entries.
Suggested fix
De-duplicate identical literal include items when the censor tree is built (CCensorNode::AddItemSimple, CPP/Common/Wildcard.cpp:345-349), or skip an entry in the direct-names loop when the same normalized path was already added.
Related
Maintainer comment on #55 (./file ./subdir/file reports Duplicate filename: "It's feature") concerns paths that normalize to the same stored name. Here the two operands are byte-identical.
- #55: the maintainer answered "It's feature" for
./file ./subdir/file. This report is about repeating the same operand being handled differently bya,handl/x/t/d.
Found with a differential test setup (a model of the documented behavior, and for some reports an independent tool such as libarchive/bsdtar, compared against the real binary) and then checked by hand: every command above was re-run verbatim on the tested build, and the root cause was read in the source. Tested commit: d3296e3 (26.06).
- Dominant language
- C++
- Stars
- 4.6k
- Forks
- 519
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ip7z/7zip
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
area::installer documentation engine::sd enhancement wg::platform-core
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
lemonade-sdk/lemonade#4349 ·
Maintainers usually reply within 1 day
-
Python example: list a model's scenes and their camerasPossibly taken @rudraparmar76 claimed this today. Opendocumentation good first issue python
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
iamahsanmehmood/openskp#796 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tenstorrent/tt-umd#4183 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
odelaneau/GLIMPSE#353 · 1 comment ·
Maintainers usually reply within 4 days