MCPcopy Create free account
hub / github.com/AdRoll/baker / processListFile

Method processListFile

input/list.go:218–260  ·  view source on GitHub ↗
(f io.Reader)

Source from the content-addressed store, hash-verified

216}
217
218func (s *List) processListFile(f io.Reader) {
219
220 // Parse the list file line by line, in a way that allows
221 // us to also check the status of the s.ci.Done channel
222 // to abort.
223 // This handles the case in which we're reading from stdin
224 // which is possibly never closed, but we still want to abort
225 // (eg: CTRL+C).
226 lines := make(chan string, 8)
227
228 go func() {
229 scanner := bufio.NewScanner(f)
230 for scanner.Scan() {
231 line := scanner.Text()
232 if line == "" {
233 continue
234 }
235 err := scanner.Err()
236 if err != nil {
237 log.WithError(err).Fatal("Failed to scan list input file.")
238 }
239 lines <- line
240 }
241 err := scanner.Err()
242 if err != nil {
243 log.WithError(err).Fatal("Failed to scan list input file.")
244 }
245 close(lines)
246 }()
247
248 for {
249 select {
250 case line, ok := <-lines:
251 if !ok {
252 return
253 }
254
255 s.processFileOrList(line)
256 case <-s.ci.Done:
257 return
258 }
259 }
260}
261
262func (s *List) processList(fn string) error {
263 if fn == "-" {

Callers 1

processListMethod · 0.95

Calls 1

processFileOrListMethod · 0.95

Tested by

no test coverage detected