fix 500 when edit hook (#8782) (#8790)

This commit is contained in:
Lunny Xiao 2019-11-03 02:31:29 +08:00 committed by techknowlogick
parent f104898989
commit 4a08d574cf
1 changed files with 5 additions and 0 deletions

View File

@ -90,6 +90,11 @@ func (h *Hook) Update() error {
h.IsActive = false
return nil
}
d := filepath.Dir(h.path)
if err := os.MkdirAll(d, os.ModePerm); err != nil {
return err
}
err := ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm)
if err != nil {
return err