diff --git a/cmd/format-fs.go b/cmd/format-fs.go index b426019fc..a75370116 100644 --- a/cmd/format-fs.go +++ b/cmd/format-fs.go @@ -350,27 +350,24 @@ func formatFSFixDeploymentID(fsFormatPath string) error { logger.Info("Another minio process(es) might be holding a lock to the file %s. Please kill that minio process(es) (elapsed %s)\n", fsFormatPath, getElapsedTime()) continue } - if err != nil { - break - } + break + } + if err != nil { + return err + } - if err = jsonLoad(wlk, format); err != nil { - break - } + defer wlk.Close() - // Check if format needs to be updated - if format.ID != "" { - err = nil - break - } - - format.ID = mustGetUUID() - if err = jsonSave(wlk, format); err != nil { - break - } + if err = jsonLoad(wlk, format); err != nil { + return err } - if wlk != nil { - wlk.Close() + + // Check if format needs to be updated + if format.ID != "" { + return nil } - return err + + // Set new UUID to the format and save it + format.ID = mustGetUUID() + return jsonSave(wlk, format) }