@cryptotaxi247 / kubo / commits / fbe40883e

Remove PresentInImport tracking as per conversation

Peter Rabbitson committed Apr 8, 2020 at 23:26 UTC fbe40883e6cd7aa7e8bc890fd54f541ce896803b
2 files changed +17 -29
core/commands/dag/dag.go
+7 -19
@@ -73,9 +73,8 @@ type CarImportOutput struct {
73 Root RootMeta
74 }
75 type RootMeta struct {
76 - Cid cid.Cid
77 - PresentInImport bool
78 - PinErrorMsg string
76 + Cid cid.Cid
77 + PinErrorMsg string
78 }
79
80 var DagPutCmd = &cmds.Command{
@@ -274,7 +273,7 @@ var DagResolveCmd = &cmds.Command{
273 }
274
275 type importResult struct {
277 - roots map[cid.Cid]bool
276 + roots map[cid.Cid]struct{}
277 err error
278 }
279
@@ -361,7 +360,7 @@ Maximum supported CAR version: 1
360 if doPinRoots {
361
362 var failedPins int
364 - for c, seen := range roots {
363 + for c := range roots {
364
365 // We need to re-retrieve a block, convert it to ipld, and feed it
366 // to the Pinning interface, sigh...
@@ -379,7 +378,7 @@ Maximum supported CAR version: 1
378 //
379 // if err := api.Pin().Add(req.Context, rp, options.Pin.Recursive(true)); err != nil {
380
382 - ret := RootMeta{Cid: c, PresentInImport: seen}
381 + ret := RootMeta{Cid: c}
382
383 if block, err := node.Blockstore.Get(c); err != nil {
384 ret.PinErrorMsg = err.Error()
@@ -430,10 +429,6 @@ Maximum supported CAR version: 1
429 event.Root.PinErrorMsg = "success"
430 }
431
433 - if !event.Root.PresentInImport {
434 - event.Root.PinErrorMsg += " (root specified in .car header without available data)"
435 - }
436 -
432 _, err = fmt.Fprintf(
433 w,
434 "Pinned root\t%s\t%s\n",
@@ -452,7 +447,7 @@ func importWorker(req *cmds.Request, re cmds.ResponseEmitter, api iface.CoreAPI,
447 // similar to pinner.Pin/pinner.Flush
448 batch := ipld.NewBatch(req.Context, api.Dag())
449
455 - roots := make(map[cid.Cid]bool)
450 + roots := make(map[cid.Cid]struct{})
451
452 it := req.Files.Entries()
453 for it.Next() {
@@ -483,9 +478,7 @@ func importWorker(req *cmds.Request, re cmds.ResponseEmitter, api iface.CoreAPI,
478 }
479
480 for _, c := range car.Header.Roots {
486 - if _, exists := roots[c]; !exists {
487 - roots[c] = false
488 - }
481 + roots[c] = struct{}{}
482 }
483
484 for {
@@ -505,11 +498,6 @@ func importWorker(req *cmds.Request, re cmds.ResponseEmitter, api iface.CoreAPI,
498 if err := batch.Add(req.Context, nd); err != nil {
499 return err
500 }
508 -
509 - // encountered something known to be a root, for the first time
510 - if seen, exists := roots[nd.Cid()]; exists && !seen {
511 - roots[nd.Cid()] = true
512 - }
501 }
502
503 return nil
test/sharness/t0054-dag-car-import-export.sh
+10 -10
@@ -42,7 +42,7 @@ run_online_imp_exp_tests() {
42 reset_blockstore 0
43 reset_blockstore 1
44
45 - echo -e "Pinned root\tbafkqaaa\tsuccess (root specified in .car header without available data)" > basic_import_expected
45 + echo -e "Pinned root\tbafkqaaa\tsuccess" > basic_import_expected
46 echo -e "Pinned root\tbafy2bzaceaxm23epjsmh75yvzcecsrbavlmkcxnva66bkdebdcnyw3bjrc74u\tsuccess" >> basic_import_expected
47 echo -e "Pinned root\tbafy2bzaced4ueelaegfs5fqu4tzsh6ywbbpfk3cxppupmxfdhbpbhzawfw5oy\tsuccess" >> basic_import_expected
48
@@ -55,8 +55,8 @@ run_online_imp_exp_tests() {
55 | sort > basic_import_actual
56 '
57
58 - # FIXME - the fact we reliably fail this is indicative of some sort of race...
59 - test_expect_failure "concurrent GC did not manage to find anything" '
58 + # FIXME - positive-test the lack of output when https://github.com/ipfs/go-ipfs/issues/7121 is addressed
59 + test_expect_failure "concurrent GC did not manage to grab anything and remained silent" '
60 ! [[ -s gc_out ]]
61 '
62 test_expect_success "basic import output as expected" '
@@ -89,8 +89,8 @@ run_online_imp_exp_tests() {
89 ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \
90 | sort > basic_fifo_import_actual
91 '
92 - # FIXME - the fact we reliably fail this is indicative of some sort of race...
93 - test_expect_failure "concurrent GC did not manage to grab anything" '
92 + # FIXME - positive-test the lack of output when https://github.com/ipfs/go-ipfs/issues/7121 is addressed
93 + test_expect_failure "concurrent GC did not manage to grab anything and remained silent" '
94 ! [[ -s gc_out ]]
95 '
96
@@ -135,9 +135,9 @@ test_expect_success "correct error" '
135
136
137 cat >multiroot_import_expected <<EOE
138 -{"Root":{"Cid":{"/":"bafy2bzaceb55n7uxyfaelplulk3ev2xz7gnq6crncf3ahnvu46hqqmpucizcw"},"PresentInImport":true,"PinErrorMsg":""}}
139 -{"Root":{"Cid":{"/":"bafy2bzacebedrc4n2ac6cqdkhs7lmj5e4xiif3gu7nmoborihajxn3fav3vdq"},"PresentInImport":true,"PinErrorMsg":""}}
140 -{"Root":{"Cid":{"/":"bafy2bzacede2hsme6hparlbr4g2x6pylj43olp4uihwjq3plqdjyrdhrv7cp4"},"PresentInImport":true,"PinErrorMsg":""}}
138 +{"Root":{"Cid":{"/":"bafy2bzaceb55n7uxyfaelplulk3ev2xz7gnq6crncf3ahnvu46hqqmpucizcw"},"PinErrorMsg":""}}
139 +{"Root":{"Cid":{"/":"bafy2bzacebedrc4n2ac6cqdkhs7lmj5e4xiif3gu7nmoborihajxn3fav3vdq"},"PinErrorMsg":""}}
140 +{"Root":{"Cid":{"/":"bafy2bzacede2hsme6hparlbr4g2x6pylj43olp4uihwjq3plqdjyrdhrv7cp4"},"PinErrorMsg":""}}
141 EOE
142 test_expect_success "multiroot import works" '
143 ipfs dag import --enc=json ../t0054-dag-car-import-export-data/lotus_testnet_export_256_multiroot.car | sort > multiroot_import_actual
@@ -159,8 +159,8 @@ test_expect_success "expected silence on --pin-roots=false" '
159
160
161 cat >naked_root_import_expected <<EOE
162 -{"Root":{"Cid":{"/":"bafy2bzaceaxm23epjsmh75yvzcecsrbavlmkcxnva66bkdebdcnyw3bjrc74u"},"PresentInImport":false,"PinErrorMsg":""}}
163 -{"Root":{"Cid":{"/":"bafy2bzaced4ueelaegfs5fqu4tzsh6ywbbpfk3cxppupmxfdhbpbhzawfw5oy"},"PresentInImport":false,"PinErrorMsg":""}}
162 +{"Root":{"Cid":{"/":"bafy2bzaceaxm23epjsmh75yvzcecsrbavlmkcxnva66bkdebdcnyw3bjrc74u"},"PinErrorMsg":""}}
163 +{"Root":{"Cid":{"/":"bafy2bzaced4ueelaegfs5fqu4tzsh6ywbbpfk3cxppupmxfdhbpbhzawfw5oy"},"PinErrorMsg":""}}
164 EOE
165 test_expect_success "naked root import works" '
166 ipfs dag import --enc=json ../t0054-dag-car-import-export-data/combined_naked_roots_genesis_and_128.car \