fix: save event hook

fix filebrowser/filebrowser#696
This commit is contained in:
Ramires Viana 2020-01-16 14:25:35 +00:00
parent 4265254325
commit f915c647d0

View File

@ -94,6 +94,11 @@ var resourcePostPutHandler = withUser(func(w http.ResponseWriter, r *http.Reques
}
}
action := "upload"
if r.Method == http.MethodPut {
action = "save"
}
err := d.RunHook(func() error {
dir, _ := filepath.Split(r.URL.Path)
err := d.user.Fs.MkdirAll(dir, 0775)
@ -121,7 +126,7 @@ var resourcePostPutHandler = withUser(func(w http.ResponseWriter, r *http.Reques
etag := fmt.Sprintf(`"%x%x"`, info.ModTime().UnixNano(), info.Size())
w.Header().Set("ETag", etag)
return nil
}, "upload", r.URL.Path, "", d.user)
}, action, r.URL.Path, "", d.user)
return errToStatus(err), err
})