mirror of https://github.com/minio/minio.git
minor cleanup
- Reused contains() from utils.go at a couple of places - Cleanup in return statements and boolean checks
This commit is contained in:
parent
ec4260d260
commit
418921de89
|
@ -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,10 +107,8 @@ 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 {
|
||||
return fs, err
|
||||
}
|
||||
return fs, nil
|
||||
err = os.MkdirAll(diskPath, 0777)
|
||||
return fs, err
|
||||
}
|
||||
return fs, err
|
||||
}
|
||||
|
|
|
@ -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…
Reference in New Issue