mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix 3238: handle errors for GenerateDirUuid method
This commit is contained in:
parent
b9f7b6fb9a
commit
8aa19577f4
|
@ -44,13 +44,11 @@ func GenerateDirUuid(dir string) (dirUuidString string, err error) {
|
||||||
dirUuidString = dirUuid.String()
|
dirUuidString = dirUuid.String()
|
||||||
writeErr := util.WriteFile(fileName, []byte(dirUuidString), 0644)
|
writeErr := util.WriteFile(fileName, []byte(dirUuidString), 0644)
|
||||||
if writeErr != nil {
|
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)
|
return "", fmt.Errorf("failed to write uuid to %s : %v", fileName, writeErr)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
uuidData, readErr := os.ReadFile(fileName)
|
uuidData, readErr := os.ReadFile(fileName)
|
||||||
if readErr != nil {
|
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)
|
return "", fmt.Errorf("failed to read uuid from %s : %v", fileName, readErr)
|
||||||
}
|
}
|
||||||
dirUuidString = string(uuidData)
|
dirUuidString = string(uuidData)
|
||||||
|
@ -65,7 +63,10 @@ func NewDiskLocation(dir string, maxVolumeCount int, minFreeSpace util.MinFreeSp
|
||||||
} else {
|
} else {
|
||||||
idxDir = util.ResolvePath(idxDir)
|
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{
|
location := &DiskLocation{
|
||||||
Directory: dir,
|
Directory: dir,
|
||||||
DirectoryUuid: dirUuid,
|
DirectoryUuid: dirUuid,
|
||||||
|
|
Loading…
Reference in a new issue