diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index 34ea70917..88f6ebadc 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -73,9 +73,8 @@ type CarImportOutput struct { Root RootMeta } type RootMeta struct { - Cid cid.Cid - PresentInImport bool - PinErrorMsg string + Cid cid.Cid + PinErrorMsg string } var DagPutCmd = &cmds.Command{ @@ -274,7 +273,7 @@ var DagResolveCmd = &cmds.Command{ } type importResult struct { - roots map[cid.Cid]bool + roots map[cid.Cid]struct{} err error } @@ -361,7 +360,7 @@ Maximum supported CAR version: 1 if doPinRoots { var failedPins int - for c, seen := range roots { + for c := range roots { // We need to re-retrieve a block, convert it to ipld, and feed it // to the Pinning interface, sigh... @@ -379,7 +378,7 @@ Maximum supported CAR version: 1 // // if err := api.Pin().Add(req.Context, rp, options.Pin.Recursive(true)); err != nil { - ret := RootMeta{Cid: c, PresentInImport: seen} + ret := RootMeta{Cid: c} if block, err := node.Blockstore.Get(c); err != nil { ret.PinErrorMsg = err.Error() @@ -430,10 +429,6 @@ Maximum supported CAR version: 1 event.Root.PinErrorMsg = "success" } - if !event.Root.PresentInImport { - event.Root.PinErrorMsg += " (root specified in .car header without available data)" - } - _, err = fmt.Fprintf( w, "Pinned root\t%s\t%s\n", @@ -452,7 +447,7 @@ func importWorker(req *cmds.Request, re cmds.ResponseEmitter, api iface.CoreAPI, // similar to pinner.Pin/pinner.Flush batch := ipld.NewBatch(req.Context, api.Dag()) - roots := make(map[cid.Cid]bool) + roots := make(map[cid.Cid]struct{}) it := req.Files.Entries() for it.Next() { @@ -483,9 +478,7 @@ func importWorker(req *cmds.Request, re cmds.ResponseEmitter, api iface.CoreAPI, } for _, c := range car.Header.Roots { - if _, exists := roots[c]; !exists { - roots[c] = false - } + roots[c] = struct{}{} } for { @@ -505,11 +498,6 @@ func importWorker(req *cmds.Request, re cmds.ResponseEmitter, api iface.CoreAPI, if err := batch.Add(req.Context, nd); err != nil { return err } - - // encountered something known to be a root, for the first time - if seen, exists := roots[nd.Cid()]; exists && !seen { - roots[nd.Cid()] = true - } } return nil diff --git a/test/sharness/t0054-dag-car-import-export.sh b/test/sharness/t0054-dag-car-import-export.sh index 2a92309f2..4bd37f19c 100755 --- a/test/sharness/t0054-dag-car-import-export.sh +++ b/test/sharness/t0054-dag-car-import-export.sh @@ -42,7 +42,7 @@ run_online_imp_exp_tests() { reset_blockstore 0 reset_blockstore 1 - echo -e "Pinned root\tbafkqaaa\tsuccess (root specified in .car header without available data)" > basic_import_expected + echo -e "Pinned root\tbafkqaaa\tsuccess" > basic_import_expected echo -e "Pinned root\tbafy2bzaceaxm23epjsmh75yvzcecsrbavlmkcxnva66bkdebdcnyw3bjrc74u\tsuccess" >> basic_import_expected echo -e "Pinned root\tbafy2bzaced4ueelaegfs5fqu4tzsh6ywbbpfk3cxppupmxfdhbpbhzawfw5oy\tsuccess" >> basic_import_expected @@ -55,8 +55,8 @@ run_online_imp_exp_tests() { | sort > basic_import_actual ' - # FIXME - the fact we reliably fail this is indicative of some sort of race... - test_expect_failure "concurrent GC did not manage to find anything" ' + # FIXME - positive-test the lack of output when https://github.com/ipfs/go-ipfs/issues/7121 is addressed + test_expect_failure "concurrent GC did not manage to grab anything and remained silent" ' ! [[ -s gc_out ]] ' test_expect_success "basic import output as expected" ' @@ -89,8 +89,8 @@ run_online_imp_exp_tests() { ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \ | sort > basic_fifo_import_actual ' - # FIXME - the fact we reliably fail this is indicative of some sort of race... - test_expect_failure "concurrent GC did not manage to grab anything" ' + # FIXME - positive-test the lack of output when https://github.com/ipfs/go-ipfs/issues/7121 is addressed + test_expect_failure "concurrent GC did not manage to grab anything and remained silent" ' ! [[ -s gc_out ]] ' @@ -135,9 +135,9 @@ test_expect_success "correct error" ' cat >multiroot_import_expected < multiroot_import_actual @@ -159,8 +159,8 @@ test_expect_success "expected silence on --pin-roots=false" ' cat >naked_root_import_expected <