fix: simplify diskMap usage to keep certain checks predictable (#12519)

Bonus: also make sure that we Sanitize() the drives only during
startup of the server, but not during disk reconnects.
This commit is contained in:
Harshavardhana
2021-06-16 14:26:26 -07:00
committed by GitHub
parent a6cbfc3600
commit 4669d19f2a
4 changed files with 27 additions and 22 deletions

View File

@@ -233,6 +233,16 @@ func newLocalXLStorage(path string) (*xlStorage, error) {
})
}
// Sanitize - sanitizes the `format.json`, cleanup tmp.
// all other future cleanups should be added here.
func (s *xlStorage) Sanitize() error {
if err := formatErasureMigrate(s.diskPath); err != nil && !errors.Is(err, os.ErrNotExist) {
return err
}
return formatErasureCleanupTmp(s.diskPath)
}
// Initialize a new storage disk.
func newXLStorage(ep Endpoint) (*xlStorage, error) {
path := ep.Path
@@ -302,14 +312,6 @@ func newXLStorage(ep Endpoint) (*xlStorage, error) {
w.Close()
Remove(filePath)
if err := formatErasureMigrate(p.diskPath); err != nil && !errors.Is(err, os.ErrNotExist) {
return p, err
}
if err := formatErasureCleanupTmp(p.diskPath); err != nil {
return p, err
}
// Success.
return p, nil
}