mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 00:04:19 +00:00
caldav, carddav: simplify with internal.IsNotFound
This commit is contained in:
parent
a419541835
commit
7eac113594
@ -198,7 +198,7 @@ func (b *backend) Options(r *http.Request) (caps []string, allow []string, err e
|
||||
|
||||
var dataReq CalendarCompRequest
|
||||
_, 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
|
||||
} else if err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -450,11 +450,10 @@ func (c *Client) SyncCollection(path string, query *SyncQuery) (*SyncResponse, e
|
||||
ret := &SyncResponse{SyncToken: ms.SyncToken}
|
||||
for _, resp := range ms.Responses {
|
||||
p, err := resp.Path()
|
||||
if err != nil {
|
||||
if err, ok := err.(*internal.HTTPError); ok && err.Code == http.StatusNotFound {
|
||||
ret.Deleted = append(ret.Deleted, p)
|
||||
continue
|
||||
}
|
||||
if internal.IsNotFound(err) {
|
||||
ret.Deleted = append(ret.Deleted, p)
|
||||
continue
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ func (b *backend) Options(r *http.Request) (caps []string, allow []string, err e
|
||||
|
||||
var dataReq AddressDataRequest
|
||||
_, 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
|
||||
} else if err != nil {
|
||||
return nil, nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user