Skip to content

Commit

Permalink
Make the linters happy
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Jun 20, 2023
1 parent fa0381c commit 32e1b91
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 28 deletions.
12 changes: 0 additions & 12 deletions pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"path/filepath"
"strconv"
"strings"
"syscall"
"time"

rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
Expand Down Expand Up @@ -525,17 +524,6 @@ func (fs *Decomposedfs) CreateHome(ctx context.Context) (err error) {
return nil
}

// The os not exists error is buried inside the xattr error,
// so we cannot just use os.IsNotExists().
func isAlreadyExists(err error) bool {
if xerr, ok := err.(*os.LinkError); ok {
if serr, ok2 := xerr.Err.(syscall.Errno); ok2 {
return serr == syscall.EEXIST
}
}
return false
}

// GetHome is called to look up the home path for a user
// It is NOT supposed to return the internal path but the external path
func (fs *Decomposedfs) GetHome(ctx context.Context) (string, error) {
Expand Down
9 changes: 0 additions & 9 deletions pkg/storage/utils/decomposedfs/grants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package decomposedfs_test

import (
"fmt"
"io/fs"
"os"
"path/filepath"

Expand All @@ -33,14 +32,6 @@ import (
"github.com/stretchr/testify/mock"
)

type testFS struct {
root string
}

func (t testFS) Open(name string) (fs.File, error) {
return os.Open(filepath.Join(t.root, name))
}

var _ = Describe("Grants", func() {
var (
env *helpers.TestEnv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func migrateSpaceIndex(indexPath, dirIndexPath, cacheKey string) error {
if err != nil {
return err
}
os.WriteFile(indexPath, d, 0600)
err = os.WriteFile(indexPath, d, 0600)
if err != nil {
return err
}
Expand Down
16 changes: 10 additions & 6 deletions pkg/storage/utils/decomposedfs/spaceidindex/spaceidindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/shamaton/msgpack/v2"
)

// Index holds space id indexes
type Index struct {
root string
name string
Expand All @@ -24,18 +25,21 @@ type readWriteCloseSeekTruncater interface {
Truncate(int64) error
}

// New returns a new index instance
func New(root, name string) *Index {
return &Index{
root: root,
name: name,
}
}

// Init initializes the index and makes sure it can be used
func (i *Index) Init() error {
// Make sure to work on an existing tree
return os.MkdirAll(filepath.Join(i.root, i.name), 0700)
}

// Load returns the content of an index
func (i *Index) Load(index string) (map[string]string, error) {
indexPath := filepath.Join(i.root, i.name, index+".mpk")
fi, err := os.Stat(indexPath)
Expand All @@ -45,21 +49,21 @@ func (i *Index) Load(index string) (map[string]string, error) {
return i.readSpaceIndex(indexPath, i.name+":"+index, fi.ModTime())
}

// func (i *Index) RemoveFromIndex(key, entry string) os.LinkError {

// Add adds an entry to an index
func (i *Index) Add(index, key string, value string) error {
return i.UpdateIndex(index, map[string]string{key: value}, []string{})
return i.updateIndex(index, map[string]string{key: value}, []string{})
}

// Remove removes an entry from the index
func (i *Index) Remove(index, key string) error {
return i.UpdateIndex(index, map[string]string{}, []string{key})
return i.updateIndex(index, map[string]string{}, []string{key})
}

func (i *Index) UpdateIndex(index string, addLinks map[string]string, removeLinks []string) error {
func (i *Index) updateIndex(index string, addLinks map[string]string, removeLinks []string) error {
indexPath := filepath.Join(i.root, i.name, index+".mpk")

var err error
// aquire writelock
// acquire writelock
var f readWriteCloseSeekTruncater
f, err = lockedfile.OpenFile(indexPath, os.O_RDWR|os.O_CREATE, 0600)
if err != nil {
Expand Down

0 comments on commit 32e1b91

Please sign in to comment.