diff --git a/fuse/ipns/ipns_unix.go b/fuse/ipns/ipns_unix.go index aa4c8fa5b..b86618c21 100644 --- a/fuse/ipns/ipns_unix.go +++ b/fuse/ipns/ipns_unix.go @@ -42,6 +42,16 @@ func InitializeKeyspace(n *core.IpfsNode, key ci.PrivKey) error { return err } + err = n.Pinning.Pin(emptyDir, false) + if err != nil { + return err + } + + err = n.Pinning.Flush() + if err != nil { + return err + } + pub := nsys.NewRoutingPublisher(n.Routing) err = pub.Publish(key, k.B58String()) if err != nil { diff --git a/importer/importer.go b/importer/importer.go index c84dfe3ab..f5f7ce7ae 100644 --- a/importer/importer.go +++ b/importer/importer.go @@ -200,6 +200,10 @@ func BuildDagFromReader(r io.Reader, ds dag.DAGService, mp pin.ManualPinner, spl if mp != nil { mp.PinWithMode(rootkey, pin.Recursive) + err := mp.Flush() + if err != nil { + return nil, err + } } return root.getDagNode() diff --git a/test/sharness/t0080-repo.sh b/test/sharness/t0080-repo.sh index c2dc851ac..4280ccedc 100755 --- a/test/sharness/t0080-repo.sh +++ b/test/sharness/t0080-repo.sh @@ -21,10 +21,16 @@ test_expect_success "added file was pinned" ' ipfs pin ls -type=recursive | grep $HASH ' -test_expect_success "'ipfs repo gc' doesnt remove file" ' - echo -n "" > empty +test_expect_success "'ipfs repo gc' succeeds" ' ipfs repo gc > gc_out_actual +' + +test_expect_success "'ipfs repo gc' looks good (empty)" ' + echo -n "" > empty test_cmp empty gc_out_actual +' + +test_expect_success "'ipfs repo gc' doesnt remove file" ' ipfs cat $HASH > out test_cmp out afile ' @@ -36,8 +42,10 @@ test_expect_success "'ipfs pin rm' succeeds" ' ' test_expect_success "file no longer pinned" ' + # we expect the welcome file to show up here + echo QmYpv2VEsxzTTXRYX3PjDg961cnJE3kY1YDXLycHGQ3zZB > expected2 ipfs pin ls -type=recursive > actual2 - test_cmp empty actual2 + test_cmp expected2 actual2 ' test_expect_success "recursively pin afile" ' @@ -76,8 +84,10 @@ test_expect_success "'ipfs repo gc' removes file" ' ' test_expect_success "'ipfs refs local' no longer shows file" ' + echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn > expected8 + echo QmYpv2VEsxzTTXRYX3PjDg961cnJE3kY1YDXLycHGQ3zZB >> expected8 ipfs refs local > actual8 - test_cmp empty actual8 + test_cmp expected8 actual8 ' test_expect_success "adding multiblock random file succeeds" ' @@ -104,15 +114,19 @@ test_expect_success "pin something directly" ' ' test_expect_success "'ipfs pin ls -type=direct' is correct" ' - echo $DIRECTPIN > directpinhash - ipfs pin ls -type=direct > directpinout - test_cmp directpinhash directpinout + echo $DIRECTPIN > directpinexpected + echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn >> directpinexpected + cat directpinexpected | sort > dp_exp_sorted + ipfs pin ls -type=direct | sort > directpinout + test_cmp dp_exp_sorted directpinout ' test_expect_success "'ipfs pin ls -type=recursive' is correct" ' echo $MBLOCKHASH > rp_expected - ipfs pin ls -type=recursive > rp_actual - test_cmp rp_expected rp_actual + echo QmYpv2VEsxzTTXRYX3PjDg961cnJE3kY1YDXLycHGQ3zZB >> rp_expected + cat rp_expected | sort > rp_exp_sorted + ipfs pin ls -type=recursive | sort > rp_actual + test_cmp rp_exp_sorted rp_actual ' test_expect_success "'ipfs pin ls -type=all' is correct" '