correct .vif file creation

This commit is contained in:
Chris Lu 2019-12-28 21:40:12 -08:00
parent b6f7033478
commit 03ab0b1b9a

View file

@ -52,10 +52,8 @@ func MaybeLoadVolumeInfo(fileName string) (*volume_server_pb.VolumeInfo, bool) {
func SaveVolumeInfo(fileName string, volumeInfo *volume_server_pb.VolumeInfo) error { func SaveVolumeInfo(fileName string, volumeInfo *volume_server_pb.VolumeInfo) error {
tierFileName := fileName + ".vif" if exists, _, canWrite, _, _ := util.CheckFile(fileName); exists && !canWrite {
return fmt.Errorf("%s not writable", fileName)
if exists, _, canWrite, _, _ := util.CheckFile(tierFileName); exists && !canWrite {
return fmt.Errorf("%s not writable", tierFileName)
} }
m := jsonpb.Marshaler{ m := jsonpb.Marshaler{
@ -68,9 +66,9 @@ func SaveVolumeInfo(fileName string, volumeInfo *volume_server_pb.VolumeInfo) er
return fmt.Errorf("marshal to %s: %v", fileName, marshalErr) return fmt.Errorf("marshal to %s: %v", fileName, marshalErr)
} }
writeErr := ioutil.WriteFile(tierFileName, []byte(text), 0755) writeErr := ioutil.WriteFile(fileName, []byte(text), 0755)
if writeErr != nil { if writeErr != nil {
return fmt.Errorf("fail to write %s : %v", tierFileName, writeErr) return fmt.Errorf("fail to write %s : %v", fileName, writeErr)
} }
return nil return nil