Skip to content

Commit

Permalink
refactor: Removing ioutil as deprecated
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Mar 26, 2021
1 parent 1450ec5 commit 90a0004
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
3 changes: 1 addition & 2 deletions pkg/crud/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"path"

"github.com/ViBiOh/fibr/pkg/provider"
Expand Down Expand Up @@ -43,7 +42,7 @@ func (a *app) loadMetadata() error {
return err
}

rawMeta, err := ioutil.ReadAll(file)
rawMeta, err := io.ReadAll(file)
if err != nil {
return err

Expand Down
3 changes: 1 addition & 2 deletions pkg/crud/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package crud
import (
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"strings"
Expand All @@ -30,7 +29,7 @@ func parseMultipart(r *http.Request) (string, *multipart.Part, error) {

switch part.FormName() {
case "method":
value, err := ioutil.ReadAll(part)
value, err := io.ReadAll(part)
if err != nil {
return "", nil, err
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/filesystem/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -94,14 +93,19 @@ func (a *app) List(pathname string) ([]provider.StorageItem, error) {

fullpath := a.getFullPath(pathname)

files, err := ioutil.ReadDir(fullpath)
files, err := os.ReadDir(fullpath)
if err != nil {
return nil, convertError(err)
}

items := make([]provider.StorageItem, 0)
for _, file := range files {
item := convertToItem(a.getRelativePath(path.Join(fullpath, file.Name())), file)
fileInfo, err := file.Info()
if err != nil {
return nil, fmt.Errorf("unable to read file metadata: %s", err)
}

item := convertToItem(a.getRelativePath(path.Join(fullpath, file.Name())), fileInfo)
if a.ignoreFn != nil && a.ignoreFn(item) {
continue
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/provider/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package provider
import (
"errors"
"io"
"io/ioutil"
"reflect"
"testing"
)
Expand Down Expand Up @@ -89,7 +88,7 @@ func TestSafeWrite(t *testing.T) {
{
"no panic",
args{
writer: ioutil.Discard,
writer: io.Discard,
content: "test",
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/thumbnail/thumbnail.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/base64"
"flag"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"

Expand Down Expand Up @@ -134,7 +134,7 @@ func (a app) List(w http.ResponseWriter, _ *http.Request, item provider.StorageI
logger.Error("unable to open %s: %s", item.Pathname, err)
}

content, err := ioutil.ReadAll(file)
content, err := io.ReadAll(file)
if err != nil {
logger.Error("unable to read %s: %s", item.Pathname, err)
}
Expand Down

0 comments on commit 90a0004

Please sign in to comment.