mirror of
https://github.com/pgsty/minio.git
synced 2026-07-20 04:30:26 +03:00
Remove deprecated io/ioutil (#15707)
This commit is contained in:
@@ -24,7 +24,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -449,7 +448,7 @@ func (c *esClientV7) createIndex(args ElasticsearchArgs) error {
|
||||
err := fmt.Errorf("Create index err: %s", res.String())
|
||||
return err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
@@ -462,7 +461,7 @@ func (c *esClientV7) ping(ctx context.Context, _ ElasticsearchArgs) (bool, error
|
||||
if err != nil {
|
||||
return false, errNotConnected
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
resp.Body.Close()
|
||||
return !resp.IsError(), nil
|
||||
}
|
||||
@@ -476,7 +475,7 @@ func (c *esClientV7) entryExists(ctx context.Context, index string, key string)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, res.Body)
|
||||
io.Copy(io.Discard, res.Body)
|
||||
res.Body.Close()
|
||||
return !res.IsError(), nil
|
||||
}
|
||||
@@ -493,7 +492,7 @@ func (c *esClientV7) removeEntry(ctx context.Context, index string, key string)
|
||||
return err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
defer io.Copy(ioutil.Discard, res.Body)
|
||||
defer io.Copy(io.Discard, res.Body)
|
||||
if res.IsError() {
|
||||
return fmt.Errorf("Delete err: %s", res.String())
|
||||
}
|
||||
@@ -522,7 +521,7 @@ func (c *esClientV7) updateEntry(ctx context.Context, index string, key string,
|
||||
return err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
defer io.Copy(ioutil.Discard, res.Body)
|
||||
defer io.Copy(io.Discard, res.Body)
|
||||
if res.IsError() {
|
||||
return fmt.Errorf("Update err: %s", res.String())
|
||||
}
|
||||
@@ -549,7 +548,7 @@ func (c *esClientV7) addEntry(ctx context.Context, index string, eventData event
|
||||
return err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
defer io.Copy(ioutil.Discard, res.Body)
|
||||
defer io.Copy(io.Discard, res.Body)
|
||||
if res.IsError() {
|
||||
return fmt.Errorf("Add err: %s", res.String())
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package target
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -87,7 +86,7 @@ func (store *QueueStore) write(key string, e event.Event) error {
|
||||
}
|
||||
|
||||
path := filepath.Join(store.directory, key+eventExt)
|
||||
if err := ioutil.WriteFile(path, eventData, os.FileMode(0o770)); err != nil {
|
||||
if err := os.WriteFile(path, eventData, os.FileMode(0o770)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -124,7 +123,7 @@ func (store *QueueStore) Get(key string) (event event.Event, err error) {
|
||||
}(store)
|
||||
|
||||
var eventData []byte
|
||||
eventData, err = ioutil.ReadFile(filepath.Join(store.directory, key+eventExt))
|
||||
eventData, err = os.ReadFile(filepath.Join(store.directory, key+eventExt))
|
||||
if err != nil {
|
||||
return event, err
|
||||
}
|
||||
@@ -179,14 +178,22 @@ func (store *QueueStore) List() ([]string, error) {
|
||||
// list lock less.
|
||||
func (store *QueueStore) list() ([]string, error) {
|
||||
var names []string
|
||||
files, err := ioutil.ReadDir(store.directory)
|
||||
files, err := os.ReadDir(store.directory)
|
||||
if err != nil {
|
||||
return names, err
|
||||
}
|
||||
|
||||
// Sort the dentries.
|
||||
sort.Slice(files, func(i, j int) bool {
|
||||
return files[i].ModTime().Before(files[j].ModTime())
|
||||
ii, err := files[i].Info()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
ji, err := files[j].Info()
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
return ii.ModTime().Before(ji.ModTime())
|
||||
})
|
||||
|
||||
for _, file := range files {
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -135,7 +134,7 @@ func (target *WebhookTarget) IsActive() (bool, error) {
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
resp.Body.Close()
|
||||
// No network failure i.e response from the target means its up
|
||||
return true, nil
|
||||
@@ -194,7 +193,7 @@ func (target *WebhookTarget) send(eventData event.Event) error {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||
target.Close()
|
||||
|
||||
Reference in New Issue
Block a user