mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
fix: unwrapping issues with os.Is* functions (#10949)
reduces 3 stat calls, reducing the overall startup time significantly.
This commit is contained in:
@@ -19,6 +19,7 @@ package cmd
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -80,14 +81,11 @@ func formatErasureMigrateLocalEndpoints(endpoints Endpoints) error {
|
||||
index := index
|
||||
g.Go(func() error {
|
||||
epPath := endpoints[index].Path
|
||||
formatPath := pathJoin(epPath, minioMetaBucket, formatConfigFile)
|
||||
if _, err := os.Stat(formatPath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unable to access (%s) %w", formatPath, err)
|
||||
err := formatErasureMigrate(epPath)
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
return err
|
||||
}
|
||||
return formatErasureMigrate(epPath)
|
||||
return nil
|
||||
}, index)
|
||||
}
|
||||
for _, err := range g.Wait() {
|
||||
@@ -108,22 +106,6 @@ func formatErasureCleanupTmpLocalEndpoints(endpoints Endpoints) error {
|
||||
index := index
|
||||
g.Go(func() error {
|
||||
epPath := endpoints[index].Path
|
||||
// If disk is not formatted there is nothing to be cleaned up.
|
||||
formatPath := pathJoin(epPath, minioMetaBucket, formatConfigFile)
|
||||
if _, err := os.Stat(formatPath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unable to access (%s) %w", formatPath, err)
|
||||
}
|
||||
if _, err := os.Stat(pathJoin(epPath, minioMetaTmpBucket+"-old")); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return fmt.Errorf("unable to access (%s) %w",
|
||||
pathJoin(epPath, minioMetaTmpBucket+"-old"),
|
||||
err)
|
||||
}
|
||||
}
|
||||
|
||||
// Need to move temporary objects left behind from previous run of minio
|
||||
// server to a unique directory under `minioMetaTmpBucket-old` to clean
|
||||
// up `minioMetaTmpBucket` for the current run.
|
||||
|
||||
Reference in New Issue
Block a user