Skip to content

Commit

Permalink
Merge pull request #77 from keep-network/expose-checkStoragePermission
Browse files Browse the repository at this point in the history
Expose checkStoragePermission as a Public Function

What we really want here is to adjust persistence.Handle to provide support
for multiple storage areas, some of which need the current/archive/snapshot
behavior and some of which just store data normally. For now, we expose functions
like this one until time can be invested to export a higher-level abstraction and
unexport these lower-level details.
  • Loading branch information
Shadowfiend committed May 5, 2021
2 parents f16f7bd + 6522def commit 63e27dd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/persistence/disk_persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 63e27dd

Please sign in to comment.