| 418 | } |
| 419 | |
| 420 | func getFilesToAdd(file string, content []byte) (map[string]*gistFileToUpdate, error) { |
| 421 | if shared.IsBinaryContents(content) { |
| 422 | return nil, fmt.Errorf("failed to upload %s: binary file not supported", file) |
| 423 | } |
| 424 | |
| 425 | if len(content) == 0 { |
| 426 | return nil, errors.New("file contents cannot be empty") |
| 427 | } |
| 428 | |
| 429 | filename := filepath.Base(file) |
| 430 | return map[string]*gistFileToUpdate{ |
| 431 | filename: { |
| 432 | NewFilename: filename, |
| 433 | Content: string(content), |
| 434 | }, |
| 435 | }, nil |
| 436 | } |
| 437 | |
| 438 | func getFilesToRemove(gist gistToUpdate, filename string) (map[string]*gistFileToUpdate, error) { |
| 439 | if _, found := gist.Files[filename]; !found { |