MCPcopy Index your code
hub / github.com/devspace-sh/devspace / downloadFile

Function downloadFile

pkg/devspace/server/download.go:72–98  ·  view source on GitHub ↗
(version string, folder string)

Source from the content-addressed store, hash-verified

70}
71
72func downloadFile(version string, folder string) error {
73 uiBytes, err := assets.Asset("release/ui.tar.gz")
74 if err == nil {
75 return untar(bytes.NewReader(uiBytes), folder)
76 }
77
78 // Create download url
79 if version == "latest" {
80 version, err = git.GetLatestVersion(UIRepository)
81 if err != nil {
82 return errors.Wrap(err, "get latest version")
83 }
84 }
85
86 url := fmt.Sprintf("%s/%s/%s", UIDownloadBaseURL, version, "ui.tar.gz")
87 resp, err := http.Get(url)
88 if err != nil {
89 return errors.Wrap(err, "download ui archive")
90 }
91 defer resp.Body.Close()
92
93 if resp.StatusCode != http.StatusOK {
94 return fmt.Errorf("unexpected response status: %d", resp.StatusCode)
95 }
96
97 return untar(resp.Body, folder)
98}
99
100func untar(r io.Reader, dir string) (err error) {
101 t0 := time.Now()

Callers 1

downloadUITarFunction · 0.70

Calls 6

AssetFunction · 0.92
GetLatestVersionFunction · 0.92
untarFunction · 0.85
CloseMethod · 0.65
GetMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected