Repeating the same file operand: `a` fails with "Duplicate filename on disk", `h` counts the file twice, `l/x/t/d` de-duplicate
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 56/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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).
- Lingua principale
- C++
- Stelle
- 4.6k
- Fork
- 519
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ip7z/7zip
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
area::installer documentation engine::sd enhancement wg::platform-core
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
lemonade-sdk/lemonade#4349 ·
I maintainer di solito rispondono entro 1 giorno
-
Python example: list a model's scenes and their camerasForse già presa @rudraparmar76 l’ha presa oggi. Apertadocumentation good first issue python
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
iamahsanmehmood/openskp#796 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
tenstorrent/tt-umd#4183 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
odelaneau/GLIMPSE#353 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni