(w http.ResponseWriter, r *http.Request)
| 794 | } |
| 795 | |
| 796 | func (h *Handler) handleProppatch(w http.ResponseWriter, r *http.Request) (status int, err error) { |
| 797 | reqPath, status, err := h.stripPrefix(r.URL.Path) |
| 798 | if err != nil { |
| 799 | return status, err |
| 800 | } |
| 801 | release, status, err := h.confirmLocks(r, reqPath, "") |
| 802 | if err != nil { |
| 803 | return status, err |
| 804 | } |
| 805 | defer release() |
| 806 | |
| 807 | ctx := r.Context() |
| 808 | user := ctx.Value(conf.UserKey).(*model.User) |
| 809 | reqPath, err = user.JoinPath(reqPath) |
| 810 | if err != nil { |
| 811 | return http.StatusForbidden, err |
| 812 | } |
| 813 | meta, err := op.GetNearestMeta(reqPath) |
| 814 | if err != nil && !errors.Is(errors.Cause(err), errs.MetaNotFound) { |
| 815 | return http.StatusInternalServerError, err |
| 816 | } |
| 817 | if !common.CanWrite(user, meta, reqPath) { |
| 818 | return http.StatusForbidden, errs.PermissionDenied |
| 819 | } |
| 820 | if _, err := fs.Get(ctx, reqPath, &fs.GetArgs{}); err != nil { |
| 821 | if errs.IsObjectNotFound(err) { |
| 822 | return http.StatusNotFound, err |
| 823 | } |
| 824 | return http.StatusMethodNotAllowed, err |
| 825 | } |
| 826 | patches, status, err := readProppatch(r.Body) |
| 827 | if err != nil { |
| 828 | return status, err |
| 829 | } |
| 830 | pstats, err := patch(ctx, h.LockSystem, reqPath, patches) |
| 831 | if err != nil { |
| 832 | return http.StatusInternalServerError, err |
| 833 | } |
| 834 | mw := multistatusWriter{w: w} |
| 835 | writeErr := mw.write(makePropstatResponse(r.URL.Path, pstats)) |
| 836 | closeErr := mw.close() |
| 837 | if writeErr != nil { |
| 838 | return http.StatusInternalServerError, writeErr |
| 839 | } |
| 840 | if closeErr != nil { |
| 841 | return http.StatusInternalServerError, closeErr |
| 842 | } |
| 843 | return 0, nil |
| 844 | } |
| 845 | |
| 846 | func makePropstatResponse(href string, pstats []Propstat) *response { |
| 847 | resp := response{ |
no test coverage detected