minor cleanup

- Reused contains() from utils.go at a couple of places
- Cleanup in return statements and boolean checks
master
Mohit Agarwal 8 years ago committed by Harshavardhana
parent ec4260d260
commit 418921de89
  1. 20
      cmd/auth-handler.go
  2. 2
      cmd/erasure-readfile_test.go
  3. 4
      cmd/object-handlers.go
  4. 4
      cmd/posix.go
  5. 12
      cmd/rpc-server.go
  6. 10
      cmd/server-rlimit-nix.go
  7. 2
      cmd/xl-v1-list-objects.go
  8. 5
      cmd/xl-v1-metadata.go
  9. 8
      cmd/xl-v1.go
  10. 2
      dist/linux-systemd/readme.md

@ -165,22 +165,18 @@ func setAuthHandler(h http.Handler) http.Handler {
}
// List of all support S3 auth types.
var supportedS3AuthTypes = []authType{
authTypeAnonymous,
authTypePresigned,
authTypeSigned,
authTypePostPolicy,
authTypeStreamingSigned,
var supportedS3AuthTypes = map[authType]struct{}{
authTypeAnonymous: {},
authTypePresigned: {},
authTypeSigned: {},
authTypePostPolicy: {},
authTypeStreamingSigned: {},
}
// Validate if the authType is valid and supported.
func isSupportedS3AuthType(aType authType) bool {
for _, a := range supportedS3AuthTypes {
if a == aType {
return true
}
}
return false
_, ok := supportedS3AuthTypes[aType]
return ok
}
// handler for validating incoming authorization headers.

@ -112,7 +112,7 @@ func testGetReadDisks(t *testing.T, xl xlObjects) {
t.Errorf("test-case %d - expected nextIndex: %d, got : %d", i+1, test.nextIndex, nextIndex)
continue
}
if reflect.DeepEqual(test.retDisks, disks) == false {
if !reflect.DeepEqual(test.retDisks, disks) {
t.Errorf("test-case %d : incorrect disks returned. expected %+v, got %+v", i+1, test.retDisks, disks)
continue
}

@ -268,9 +268,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
}
// Skip the first element if it is '/', split the rest.
if strings.HasPrefix(objectSource, "/") {
objectSource = objectSource[1:]
}
objectSource = strings.TrimPrefix(objectSource, "/")
splits := strings.SplitN(objectSource, "/", 2)
// Save sourceBucket and sourceObject extracted from url Path.

@ -107,11 +107,9 @@ func newPosix(diskPath string) (StorageAPI, error) {
if err != nil {
if os.IsNotExist(err) {
// Disk not found create it.
if err = os.MkdirAll(diskPath, 0777); err != nil {
err = os.MkdirAll(diskPath, 0777)
return fs, err
}
return fs, nil
}
return fs, err
}
if !st.IsDir() {

@ -16,11 +16,7 @@ type storageServer struct {
// MakeVolHandler - make vol handler is rpc wrapper for MakeVol operation.
func (s *storageServer) MakeVolHandler(arg *string, reply *GenericReply) error {
err := s.storage.MakeVol(*arg)
if err != nil {
return err
}
return nil
return s.storage.MakeVol(*arg)
}
// ListVolsHandler - list vols handler is rpc wrapper for ListVols operation.
@ -46,11 +42,7 @@ func (s *storageServer) StatVolHandler(arg *string, reply *VolInfo) error {
// DeleteVolHandler - delete vol handler is a rpc wrapper for
// DeleteVol operation.
func (s *storageServer) DeleteVolHandler(arg *string, reply *GenericReply) error {
err := s.storage.DeleteVol(*arg)
if err != nil {
return err
}
return nil
return s.storage.DeleteVol(*arg)
}
/// File operations

@ -37,15 +37,7 @@ func setMaxOpenFiles() error {
// TO increase this limit further user has to manually edit
// `/etc/security/limits.conf`
rLimit.Cur = rLimit.Max
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
return err
}
err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
return err
}
return nil
return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
}
// Set max memory used by minio as a process, this value is usually

@ -76,7 +76,7 @@ func (xl xlObjects) listObjects(bucket, prefix, marker, delimiter string, maxKey
nextMarker = objInfo.Name
objInfos = append(objInfos, objInfo)
i++
if walkResult.end == true {
if walkResult.end {
eof = true
break
}

@ -137,11 +137,10 @@ func (m xlMetaV1) IsValid() bool {
}
// ObjectPartIndex - returns the index of matching object part number.
func (m xlMetaV1) ObjectPartIndex(partNumber int) (index int) {
func (m xlMetaV1) ObjectPartIndex(partNumber int) int {
for i, part := range m.Parts {
if partNumber == part.Number {
index = i
return index
return i
}
}
return -1

@ -95,13 +95,7 @@ func checkSufficientDisks(disks []string) error {
// isDiskFound - validates if the disk is found in a list of input disks.
func isDiskFound(disk string, disks []string) bool {
for _, d := range disks {
// Disk found return
if disk == d {
return true
}
}
return false
return contains(disks, disk)
}
// newXLObjects - initialize new xl object layer.

@ -26,7 +26,7 @@ EOT
Put minio.service in /etc/systemd/system/
```
curl https://raw.githubusercontent.com/minio/minio/master/dist/linux-systemd/minio.service > /etc/systemd/system/
( cd /etc/systemd/system/; curl -O https://raw.githubusercontent.com/minio/minio/master/dist/linux-systemd/minio.service )
```
Enable startup on boot

Loading…
Cancel
Save