func uploadRepo(path, cacheKey string) error { r, w := io.Pipe() tw := tar.NewWriter(w) errCh := make(chan error) go func() { err := archiver.Tar(path, tw, func(n string) bool { return strings.HasSuffix(n, ".git") || strings.Contains(n, ".git/") }) tw.Close() w.Close() errCh <- err }() // upload the tarball to the blobstore req, _ := http.NewRequest("PUT", blobstoreCacheURL(cacheKey), r) resp, err := http.DefaultClient.Do(req) if err := <-errCh; err != nil { return err } resp.Body.Close() return err }
func uploadCache(tempDir, path string) error { cachePath := tempDir + "/" + path r, w := io.Pipe() tw := tar.NewWriter(w) errCh := make(chan error) go func() { err := archiver.Tar(cachePath, tw) tw.Close() w.Close() errCh <- err }() // upload the tarball to the blobstore req, err := http.NewRequest("PUT", "http://blobstore.discoverd/cache/"+path+".tar", r) client := http.DefaultClient resp, err := client.Do(req) if err != nil { return err } resp.Body.Close() return <-errCh }
func uploadCache(tempDir, path string) error { cachePath := filepath.Join(tempDir, path) r, w := io.Pipe() tw := tar.NewWriter(w) errCh := make(chan error) go func() { err := archiver.Tar(cachePath, tw) tw.Close() w.Close() errCh <- err }() // upload the tarball to the blobstore req, err := http.NewRequest("PUT", blobstoreCacheURL(path), r) client := http.DefaultClient resp, err := client.Do(req) if err != nil { return err } resp.Body.Close() return <-errCh }