(dst string)
| 395 | } |
| 396 | |
| 397 | func createDownloadTemp(dst string) (*os.File, string, error) { |
| 398 | dir := filepath.Dir(dst) |
| 399 | base := filepath.Base(dst) |
| 400 | for i := 0; i < 100; i++ { |
| 401 | tmp := filepath.Join(dir, fmt.Sprintf(".%s.tmp-%d-%d", base, os.Getpid(), time.Now().UnixNano()+int64(i))) |
| 402 | f, err := os.OpenFile(tmp, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) |
| 403 | if errors.Is(err, os.ErrExist) { |
| 404 | continue |
| 405 | } |
| 406 | return f, tmp, err |
| 407 | } |
| 408 | return nil, "", fmt.Errorf("failed to create temporary file for %s", dst) |
| 409 | } |
| 410 | |
| 411 | func downloadDestinationPath(dst string) (string, error) { |
| 412 | for i := 0; i < 255; i++ { |
no outgoing calls
no test coverage detected