mirror of
https://github.com/minio/minio.git
synced 2025-01-25 21:53:16 -05:00
parent
355f06cfea
commit
52b55afce0
22
fs-v1-errors.go
Normal file
22
fs-v1-errors.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Minio Cloud Storage, (C) 2016 Minio, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
// errFSDiskFormat - returned when given disk format is other than FS format.
|
||||||
|
var errFSDiskFormat = errors.New("Disk is not in FS format.")
|
@ -93,6 +93,11 @@ func newFSFormatV1() (format formatConfigV1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isFSFormat - returns whether given formatConfigV1 is FS type or not.
|
||||||
|
func isFSFormat(format formatConfigV1) bool {
|
||||||
|
return format.Format == "fs"
|
||||||
|
}
|
||||||
|
|
||||||
// writes FS format (format.json) into minioMetaBucket.
|
// writes FS format (format.json) into minioMetaBucket.
|
||||||
func writeFSFormatData(storage StorageAPI, fsFormat formatConfigV1) error {
|
func writeFSFormatData(storage StorageAPI, fsFormat formatConfigV1) error {
|
||||||
metadataBytes, err := json.Marshal(fsFormat)
|
metadataBytes, err := json.Marshal(fsFormat)
|
||||||
|
4
fs-v1.go
4
fs-v1.go
@ -103,7 +103,7 @@ func newFSObjects(disk string) (ObjectLayer, error) {
|
|||||||
|
|
||||||
// loading format.json from minioMetaBucket.
|
// loading format.json from minioMetaBucket.
|
||||||
// Note: The format.json content is ignored, reserved for future use.
|
// Note: The format.json content is ignored, reserved for future use.
|
||||||
_, err = loadFormatFS(storage)
|
format, err := loadFormatFS(storage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == errFileNotFound {
|
if err == errFileNotFound {
|
||||||
// format.json doesn't exist, create it inside minioMetaBucket.
|
// format.json doesn't exist, create it inside minioMetaBucket.
|
||||||
@ -114,6 +114,8 @@ func newFSObjects(disk string) (ObjectLayer, error) {
|
|||||||
} else {
|
} else {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
} else if !isFSFormat(format) {
|
||||||
|
return nil, errFSDiskFormat
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the callback that should be called when the process shuts down.
|
// Register the callback that should be called when the process shuts down.
|
||||||
|
@ -31,9 +31,31 @@ func TestNewFS(t *testing.T) {
|
|||||||
disk := filepath.Join(os.TempDir(), "minio-"+nextSuffix())
|
disk := filepath.Join(os.TempDir(), "minio-"+nextSuffix())
|
||||||
defer removeAll(disk)
|
defer removeAll(disk)
|
||||||
|
|
||||||
// Initializes single disk, validate if there is no error.
|
// Setup to test errFSDiskFormat.
|
||||||
_, err := newFSObjects(disk)
|
disks := []string{}
|
||||||
|
for i := 0; i < 6; i++ {
|
||||||
|
xlDisk := filepath.Join(os.TempDir(), "minio-"+nextSuffix())
|
||||||
|
defer removeAll(xlDisk)
|
||||||
|
disks = append(disks, xlDisk)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initializes all disks with XL
|
||||||
|
_, err := newXLObjects(disks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to initialize erasure, %s", err)
|
t.Fatalf("Unable to initialize XL object, %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
disk string
|
||||||
|
expectedErr error
|
||||||
|
}{
|
||||||
|
{disk, nil},
|
||||||
|
{disks[0], errFSDiskFormat},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
if _, err := newFSObjects(testCase.disk); err != testCase.expectedErr {
|
||||||
|
t.Fatalf("expected: %s, got: %s", testCase.expectedErr, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user