diff options
| author | garenchan <garenchan23@gmail.com> | 2022-06-27 22:04:50 +0800 |
|---|---|---|
| committer | garenchan <garenchan23@gmail.com> | 2022-06-27 22:04:50 +0800 |
| commit | 8aa19577f4f755fc47dafa408da8bfcc23e3ffca (patch) | |
| tree | 1f949ea7c40dab9347d6d8b1d2751070870b24be | |
| parent | b9f7b6fb9a486a9509db7ca800c9f876911413ad (diff) | |
| download | seaweedfs-8aa19577f4f755fc47dafa408da8bfcc23e3ffca.tar.xz seaweedfs-8aa19577f4f755fc47dafa408da8bfcc23e3ffca.zip | |
fix 3238: handle errors for GenerateDirUuid method
| -rw-r--r-- | weed/storage/disk_location.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go index 289fd3b47..847324838 100644 --- a/weed/storage/disk_location.go +++ b/weed/storage/disk_location.go @@ -44,13 +44,11 @@ func GenerateDirUuid(dir string) (dirUuidString string, err error) { dirUuidString = dirUuid.String() writeErr := util.WriteFile(fileName, []byte(dirUuidString), 0644) if writeErr != nil { - glog.Warningf("failed to write uuid to %s : %v", fileName, writeErr) return "", fmt.Errorf("failed to write uuid to %s : %v", fileName, writeErr) } } else { uuidData, readErr := os.ReadFile(fileName) if readErr != nil { - glog.Warningf("failed to read uuid from %s : %v", fileName, readErr) return "", fmt.Errorf("failed to read uuid from %s : %v", fileName, readErr) } dirUuidString = string(uuidData) @@ -65,7 +63,10 @@ func NewDiskLocation(dir string, maxVolumeCount int, minFreeSpace util.MinFreeSp } else { idxDir = util.ResolvePath(idxDir) } - dirUuid, _ := GenerateDirUuid(dir) + dirUuid, err := GenerateDirUuid(dir) + if err != nil { + glog.Fatalf("cannot generate uuid of dir %s: %v", dir, err) + } location := &DiskLocation{ Directory: dir, DirectoryUuid: dirUuid, |
