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. 6
      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. // List of all support S3 auth types.
var supportedS3AuthTypes = []authType{ var supportedS3AuthTypes = map[authType]struct{}{
authTypeAnonymous, authTypeAnonymous: {},
authTypePresigned, authTypePresigned: {},
authTypeSigned, authTypeSigned: {},
authTypePostPolicy, authTypePostPolicy: {},
authTypeStreamingSigned, authTypeStreamingSigned: {},
} }
// Validate if the authType is valid and supported. // Validate if the authType is valid and supported.
func isSupportedS3AuthType(aType authType) bool { func isSupportedS3AuthType(aType authType) bool {
for _, a := range supportedS3AuthTypes { _, ok := supportedS3AuthTypes[aType]
if a == aType { return ok
return true
}
}
return false
} }
// handler for validating incoming authorization headers. // 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) t.Errorf("test-case %d - expected nextIndex: %d, got : %d", i+1, test.nextIndex, nextIndex)
continue 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) t.Errorf("test-case %d : incorrect disks returned. expected %+v, got %+v", i+1, test.retDisks, disks)
continue 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. // Skip the first element if it is '/', split the rest.
if strings.HasPrefix(objectSource, "/") { objectSource = strings.TrimPrefix(objectSource, "/")
objectSource = objectSource[1:]
}
splits := strings.SplitN(objectSource, "/", 2) splits := strings.SplitN(objectSource, "/", 2)
// Save sourceBucket and sourceObject extracted from url Path. // Save sourceBucket and sourceObject extracted from url Path.

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

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

@ -37,15 +37,7 @@ func setMaxOpenFiles() error {
// TO increase this limit further user has to manually edit // TO increase this limit further user has to manually edit
// `/etc/security/limits.conf` // `/etc/security/limits.conf`
rLimit.Cur = rLimit.Max rLimit.Cur = rLimit.Max
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) return 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
} }
// Set max memory used by minio as a process, this value is usually // 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 nextMarker = objInfo.Name
objInfos = append(objInfos, objInfo) objInfos = append(objInfos, objInfo)
i++ i++
if walkResult.end == true { if walkResult.end {
eof = true eof = true
break break
} }

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

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

@ -26,7 +26,7 @@ EOT
Put minio.service in /etc/systemd/system/ 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 Enable startup on boot

Loading…
Cancel
Save