caldav, carddav: simplify with internal.IsNotFound

This commit is contained in:
Simon Ser 2022-05-03 20:15:21 +02:00
parent a419541835
commit 7eac113594
3 changed files with 6 additions and 7 deletions

View File

@ -198,7 +198,7 @@ func (b *backend) Options(r *http.Request) (caps []string, allow []string, err e
var dataReq CalendarCompRequest var dataReq CalendarCompRequest
_, err = b.Backend.GetCalendarObject(r.Context(), r.URL.Path, &dataReq) _, err = b.Backend.GetCalendarObject(r.Context(), r.URL.Path, &dataReq)
if httpErr, ok := err.(*internal.HTTPError); ok && httpErr.Code == http.StatusNotFound { if internal.IsNotFound(err) {
return caps, []string{http.MethodOptions, http.MethodPut}, nil return caps, []string{http.MethodOptions, http.MethodPut}, nil
} else if err != nil { } else if err != nil {
return nil, nil, err return nil, nil, err

View File

@ -450,11 +450,10 @@ func (c *Client) SyncCollection(path string, query *SyncQuery) (*SyncResponse, e
ret := &SyncResponse{SyncToken: ms.SyncToken} ret := &SyncResponse{SyncToken: ms.SyncToken}
for _, resp := range ms.Responses { for _, resp := range ms.Responses {
p, err := resp.Path() p, err := resp.Path()
if err != nil { if internal.IsNotFound(err) {
if err, ok := err.(*internal.HTTPError); ok && err.Code == http.StatusNotFound { ret.Deleted = append(ret.Deleted, p)
ret.Deleted = append(ret.Deleted, p) continue
continue } else if err != nil {
}
return nil, err return nil, err
} }

View File

@ -252,7 +252,7 @@ func (b *backend) Options(r *http.Request) (caps []string, allow []string, err e
var dataReq AddressDataRequest var dataReq AddressDataRequest
_, err = b.Backend.GetAddressObject(r.Context(), r.URL.Path, &dataReq) _, err = b.Backend.GetAddressObject(r.Context(), r.URL.Path, &dataReq)
if httpErr, ok := err.(*internal.HTTPError); ok && httpErr.Code == http.StatusNotFound { if internal.IsNotFound(err) {
return caps, []string{http.MethodOptions, http.MethodPut}, nil return caps, []string{http.MethodOptions, http.MethodPut}, nil
} else if err != nil { } else if err != nil {
return nil, nil, err return nil, nil, err