Merge pull request #3344 from nats-io/fix_ioutil

Remove io/ioutil
This commit is contained in:
Ivan Kozlovic
2022-08-05 13:29:33 -06:00
committed by GitHub
2 changed files with 5 additions and 6 deletions

View File

@@ -694,7 +694,7 @@ func (s *Server) configAllJetStreamAccounts() error {
// clustered stream removal will perform this cleanup as well
// this is mainly for initial cleanup
saccName := s.sys.account.Name
accStoreDirs, _ := ioutil.ReadDir(js.config.StoreDir)
accStoreDirs, _ := os.ReadDir(js.config.StoreDir)
for _, acc := range accStoreDirs {
if accName := acc.Name(); accName != saccName {
// no op if not empty

View File

@@ -23,7 +23,6 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
@@ -3784,10 +3783,10 @@ func TestJetStreamClusterAccountPurge(t *testing.T) {
sysDirs := 0
accDirs := 0
for _, s := range c.servers {
files, err := ioutil.ReadDir(s.getOpts().StoreDir + "/jetstream/" + syspub + "/_js_/")
files, err := os.ReadDir(s.getOpts().StoreDir + "/jetstream/" + syspub + "/_js_/")
require_NoError(t, err)
sysDirs += len(files) - 1 // sub 1 for _meta_
files, err = ioutil.ReadDir(s.getOpts().StoreDir + "/jetstream/" + accpub + "/streams/")
files, err = os.ReadDir(s.getOpts().StoreDir + "/jetstream/" + accpub + "/streams/")
if err == nil || (err != nil && err.(*os.PathError).Error() == "no such file or directory") {
accDirs += len(files)
}
@@ -3932,10 +3931,10 @@ func TestJetStreamAccountPurge(t *testing.T) {
inspectDirs := func(t *testing.T, accTotal int) error {
t.Helper()
if accTotal == 0 {
files, err := ioutil.ReadDir(o.StoreDir + "/jetstream/" + accpub)
files, err := os.ReadDir(o.StoreDir + "/jetstream/" + accpub)
require_True(t, len(files) == accTotal || err != nil)
} else {
files, err := ioutil.ReadDir(o.StoreDir + "/jetstream/" + accpub + "/streams")
files, err := os.ReadDir(o.StoreDir + "/jetstream/" + accpub + "/streams")
require_NoError(t, err)
require_True(t, len(files) == accTotal)
}