mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-19 01:39:35 +08:00
Fix refs -r -u for #1211
License: MIT Signed-off-by: Gaetan Voyer-Perrault <gatesvp@gmail.com>
This commit is contained in:

committed by
Juan Batiz-Benet

parent
a5521fcc76
commit
8fe7d2f571
@ -232,10 +232,6 @@ func (rw *RefWriter) writeRefsRecursive(n *dag.Node) (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if rw.skip(nkey) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
var count int
|
||||
for i, ng := range rw.DAG.GetDAG(rw.Ctx, n) {
|
||||
lk := key.Key(n.Links[i].Hash)
|
||||
|
@ -163,6 +163,30 @@ test_expect_success "'ipfs pin ls --type=all --quiet' is correct" '
|
||||
test_sort_cmp allpins_uniq_hashes actual_allpins
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs refs --unique' is correct" '
|
||||
mkdir -p uniques &&
|
||||
cd uniques &&
|
||||
echo "content1" > file1 &&
|
||||
echo "content1" > file2 &&
|
||||
ROOT=$(ipfs add -r -q . | tail -n1) &&
|
||||
ipfs refs --unique $ROOT >expected &&
|
||||
ipfs add -q file1 >unique_hash &&
|
||||
test_cmp expected unique_hash
|
||||
'
|
||||
|
||||
test_expect_success "'ipfs refs --unique --recursive' is correct" '
|
||||
mkdir -p a/b/c &&
|
||||
echo "c1" > a/f1 &&
|
||||
echo "c1" > a/b/f1 &&
|
||||
echo "c1" > a/b/c/f1 &&
|
||||
echo "c2" > a/b/c/f2 &&
|
||||
ROOT=$(ipfs add -r -q a | tail -n1) &&
|
||||
ipfs refs --unique --recursive $ROOT >refs_output &&
|
||||
wc -l refs_output | sed "s/^ *//g" >line_count &&
|
||||
echo "4 refs_output" >expected &&
|
||||
test_cmp expected line_count
|
||||
'
|
||||
|
||||
test_kill_ipfs_daemon
|
||||
|
||||
test_done
|
||||
|
Reference in New Issue
Block a user