Skip to content

Commit

Permalink
fix: save event hook
Browse files Browse the repository at this point in the history
fix #696
  • Loading branch information
ramiresviana committed Jun 17, 2020
1 parent dd40b0d commit 82c883f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion http/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
})
Expand Down

0 comments on commit 82c883f

Please sign in to comment.