in dth/client.go [200:231]
func (c *S3Client) listPrefixFn(ctx context.Context, depth int, prefix *string, maxKeys int32, levelCh chan<- *string, listCh chan struct{}, wg *sync.WaitGroup) {
defer wg.Done()
listCh <- struct{}{}
if depth == 0 {
levelCh <- prefix
return
}
continuationToken := ""
delimiter := "/"
i := 0
for continuationToken != "End" {
output, err := c.listObjectFn(ctx, &continuationToken, prefix, &delimiter, maxKeys)
if err != nil {
log.Fatalf("Failed to list prefixes in /%s for bucket %s, quit the process. Please try again later.", *prefix, c.bucket)
}
for _, cp := range output.CommonPrefixes {
i++
wg.Add(1)
go c.listPrefixFn(ctx, depth-1, cp.Prefix, maxKeys, levelCh, listCh, wg)
}
}
if i == 0 {
levelCh <- prefix
}
<-listCh
}