From 04a422523a008a655e3b4eac3ae7b524b3afc38b Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Wed, 1 Jun 2022 11:55:03 +0200 Subject: [PATCH] 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. --- storage/filesystem.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/filesystem.go b/storage/filesystem.go index 04e383d..ce9f00b 100644 --- a/storage/filesystem.go +++ b/storage/filesystem.go @@ -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) }