~sircmpwn/tokidoki-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] storage/filesystem: simplify UserPrincipalBackend

Details
Message ID
<20220524103922.104005-1-contact@emersion.fr>
DKIM signature
missing
Download raw message
Patch: +7 -11
Use composition to expose UserPrincipalBackend in filesystemBackend.
That way, no need to re-define the CurrentUserPrincipal method.
---
 storage/filesystem.go | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/storage/filesystem.go b/storage/filesystem.go
index cd19f4d0a6c5..04e383df7562 100644
--- a/storage/filesystem.go
+++ b/storage/filesystem.go
@@ -26,10 +26,10 @@ import (
)

type filesystemBackend struct {
	path                 string
	caldavPrefix         string
	carddavPrefix        string
	userPrincipalBackend webdav.UserPrincipalBackend
	webdav.UserPrincipalBackend
	path          string
	caldavPrefix  string
	carddavPrefix string
}

var (
@@ -45,20 +45,16 @@ func NewFilesystem(fsPath, caldavPrefix, carddavPrefix string, userPrincipalBack
		return nil, nil, fmt.Errorf("base path for filesystem backend must be a directory")
	}
	backend := &filesystemBackend{
		UserPrincipalBackend: userPrincipalBackend,
		path:                 fsPath,
		caldavPrefix:         caldavPrefix,
		carddavPrefix:        carddavPrefix,
		userPrincipalBackend: userPrincipalBackend,
	}
	return backend, backend, nil
}

func (b *filesystemBackend) CurrentUserPrincipal(ctx context.Context) (string, error) {
	return b.userPrincipalBackend.CurrentUserPrincipal(ctx)
}

func (b *filesystemBackend) AddressbookHomeSetPath(ctx context.Context) (string, error) {
	upPath, err := b.userPrincipalBackend.CurrentUserPrincipal(ctx)
	upPath, err := b.CurrentUserPrincipal(ctx)
	if err != nil {
		return "", err
	}
@@ -67,7 +63,7 @@ func (b *filesystemBackend) AddressbookHomeSetPath(ctx context.Context) (string,
}

func (b *filesystemBackend) CalendarHomeSetPath(ctx context.Context) (string, error) {
	upPath, err := b.userPrincipalBackend.CurrentUserPrincipal(ctx)
	upPath, err := b.CurrentUserPrincipal(ctx)
	if err != nil {
		return "", err
	}
-- 
2.36.1
Details
Message ID
<20220524115525.170840-1-ch@bitfehler.net>
In-Reply-To
<20220524103922.104005-1-contact@emersion.fr> (view parent)
DKIM signature
missing
Download raw message
From: Simon Ser <contact@emersion.fr>

Thanks!
Reply to thread Export thread (mbox)