fix: save event hook

fix filebrowser/filebrowser#696
This commit is contained in:
Ramires Viana 2020-01-16 14:25:35 +00:00
parent dd40b0d9b9
commit 82c883f95e
1 changed files with 6 additions and 1 deletions

View File

@ -93,6 +93,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)
@ -120,7 +125,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
})