deps: Update ioutil deprecated library references to os and io respectively in the client package (#16318)

* Update ioutil deprecated library references to os and io respectively

* Deal with the errors produced.

Add error handling to filEntry info
Add error handling to info
This commit is contained in:
Lance Haig
2023-03-08 20:25:10 +01:00
committed by GitHub
parent 3160c76209
commit 48e7d70fcd
34 changed files with 112 additions and 127 deletions

View File

@@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
@@ -357,12 +356,16 @@ func (d *AllocDir) List(path string) ([]*cstructs.AllocFileInfo, error) {
}
p := filepath.Join(d.AllocDir, path)
finfos, err := ioutil.ReadDir(p)
finfos, err := os.ReadDir(p)
if err != nil {
return []*cstructs.AllocFileInfo{}, err
}
files := make([]*cstructs.AllocFileInfo, len(finfos))
for idx, info := range finfos {
for idx, file := range finfos {
info, err := file.Info()
if err != nil {
return []*cstructs.AllocFileInfo{}, err
}
files[idx] = &cstructs.AllocFileInfo{
Name: info.Name(),
IsDir: info.IsDir(),