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