XL: Change AppendFile() to return only error (#1932)

AppendFile ensures that it appends the entire buffer. Returns
an error otherwise, this patch removes the necessity for the
caller to look for 'n' return on short writes.

Ref #1893
This commit is contained in:
Harshavardhana
2016-06-19 15:31:13 -07:00
committed by Anand Babu (AB) Periasamy
parent e1aad066c6
commit 50d25ca94a
11 changed files with 35 additions and 87 deletions

View File

@@ -483,7 +483,7 @@ func healFormatXL(bootstrapDisks []StorageAPI) error {
return err
}
// Fresh disk without format.json
_, _ = bootstrapDisks[index].AppendFile(minioMetaBucket, formatConfigFile, formatBytes)
_ = bootstrapDisks[index].AppendFile(minioMetaBucket, formatConfigFile, formatBytes)
// Ignore any error from AppendFile() as
// quorum might still be there to be operational.
}
@@ -605,13 +605,9 @@ func initFormatXL(storageDisks []StorageAPI) (err error) {
if err != nil {
return err
}
n, err := disk.AppendFile(minioMetaBucket, formatConfigFile, formatBytes)
if err != nil {
if err = disk.AppendFile(minioMetaBucket, formatConfigFile, formatBytes); err != nil {
return err
}
if n != int64(len(formatBytes)) {
return errUnexpected
}
}
return nil
}