func uploadItem(c *cli.Context, hash string, item client.IndexItem, bar *pb.ProgressBar, ch chan error) { data, err := ioutil.ReadFile(item.Name) if err != nil { ch <- err return } for i := 0; i < 3; i++ { err = rackClient(c).IndexUpload(hash, data) if err != nil { continue } bar.Add(item.Size) ch <- nil return } ch <- fmt.Errorf("max 3 retries on upload") return }