(ctx context.Context, url string, name string)
| 193 | } |
| 194 | |
| 195 | func downloadFile(ctx context.Context, url string, name string) error { |
| 196 | req, e := http.NewRequestWithContext(ctx, "GET", url, nil) |
| 197 | if e != nil { |
| 198 | return e |
| 199 | } |
| 200 | resp, e := http.DefaultClient.Do(req) |
| 201 | if e != nil { |
| 202 | return e |
| 203 | } |
| 204 | defer func() { _ = resp.Body.Close() }() |
| 205 | f, e := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) |
| 206 | if e != nil { |
| 207 | return e |
| 208 | } |
| 209 | defer func() { _ = f.Close() }() |
| 210 | _, e = io.Copy(f, resp.Body) |
| 211 | return e |
| 212 | } |
| 213 | |
| 214 | func ListDriveScripts(config common.Config) ([]DriveScript, error) { |
| 215 | scriptsPath, _ := config.GetDir(config.DrivesDir, false) |
no test coverage detected