From 6522def80a1e97e464fdecc94dc6f3cc41e545ad Mon Sep 17 00:00:00 2001 From: Beau Shinkle Date: Wed, 5 May 2021 11:47:42 -0400 Subject: [PATCH] Expose checkStoragePermission as a public function --- pkg/persistence/disk_persistence.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/persistence/disk_persistence.go b/pkg/persistence/disk_persistence.go index e934147..e224a20 100644 --- a/pkg/persistence/disk_persistence.go +++ b/pkg/persistence/disk_persistence.go @@ -18,7 +18,7 @@ const ( // NewDiskHandle creates on-disk data persistence handle func NewDiskHandle(path string) (Handle, error) { - err := checkStoragePermission(path) + err := CheckStoragePermission(path) if err != nil { return nil, err } @@ -152,7 +152,8 @@ func (ds *diskPersistence) getStorageCurrentDirPath() string { return fmt.Sprintf("%s/%s", ds.dataDir, currentDir) } -func checkStoragePermission(dirBasePath string) error { +// CheckStoragePermission returns an error if we don't have both read and write access to a directory. +func CheckStoragePermission(dirBasePath string) error { _, err := ioutil.ReadDir(dirBasePath) if err != nil { return fmt.Errorf("cannot read from the storage directory: [%v]", err)