Conditions | 7 |
Total Lines | 36 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | package producer |
||
28 | func (r *ReProducer) buildReproducer(ctx context.Context) func(result scan.Result) <-chan scan.Target { |
||
29 | resultRegistry := sync.Map{} |
||
30 | |||
31 | return func(result scan.Result) <-chan scan.Target { |
||
32 | resultChannel := make(chan scan.Target, defaultChannelBuffer) |
||
33 | |||
34 | go func() { |
||
35 | defer close(resultChannel) |
||
36 | |||
37 | if result.Target.Depth <= 0 { |
||
38 | return |
||
39 | } |
||
40 | |||
41 | // no point in appending to a filename |
||
42 | if urlpath.HasExtension(result.Target.Path) { |
||
43 | return |
||
44 | } |
||
45 | |||
46 | _, inRegistry := resultRegistry.Load(result.Target.Path) |
||
47 | if inRegistry { |
||
48 | return |
||
49 | } |
||
50 | |||
51 | resultRegistry.Store(result.Target.Path, nil) |
||
52 | |||
53 | for target := range r.producer.Produce(ctx) { |
||
54 | newTarget := result.Target |
||
55 | newTarget.Depth-- |
||
56 | newTarget.Path = urlpath.Join(newTarget.Path, target.Path) |
||
57 | newTarget.Method = target.Method |
||
58 | |||
59 | resultChannel <- newTarget |
||
60 | } |
||
61 | }() |
||
62 | |||
63 | return resultChannel |
||
64 | } |
||
66 |