Handle If-None-Match in PUT requests

As objects always get written to the path that is their UID, we don't
have to worry about UID conflicts. Unless, the client creates a new
contact, in which case this header should be set.
This commit is contained in:
Conrad Hoffmann 2022-06-01 11:55:03 +02:00
parent b2057fe9ef
commit 04a422523a

View File

@ -425,7 +425,8 @@ func (b *filesystemBackend) PutAddressObject(ctx context.Context, objPath string
return "", err
}
if _, err := os.Stat(localPath); !os.IsNotExist(err) {
// TODO handle IfMatch
if _, err := os.Stat(localPath); !os.IsNotExist(err) && opts.IfNoneMatch {
return "", carddav.NewPreconditionError(carddav.PreconditionNoUIDConflict)
}
@ -603,7 +604,8 @@ func (b *filesystemBackend) PutCalendarObject(ctx context.Context, objPath strin
return "", err
}
if _, err := os.Stat(localPath); !os.IsNotExist(err) {
// TODO handle IfMatch
if _, err := os.Stat(localPath); !os.IsNotExist(err) && opts.IfNoneMatch {
return "", caldav.NewPreconditionError(caldav.PreconditionNoUIDConflict)
}