Disallow binary files with gist edit -a

This commit is contained in:
Mislav Marohnić 2021-03-02 14:58:16 +01:00
parent 066ba54549
commit e16c3124dd

View file

@ -245,6 +245,14 @@ func updateGist(apiClient *api.Client, hostname string, gist *shared.Gist) error
}
func getFilesToAdd(file string) (map[string]*shared.GistFile, error) {
isBinary, err := shared.IsBinaryFile(file)
if err != nil {
return nil, fmt.Errorf("failed to read file %s: %w", file, err)
}
if isBinary {
return nil, fmt.Errorf("failed to upload %s: binary file not supported", file)
}
content, err := ioutil.ReadFile(file)
if err != nil {
return nil, fmt.Errorf("failed to read file %s: %w", file, err)