mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 08:14:15 +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
|
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
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user