Use new methods in the io and os packages instead of ioutil ones

ioutil is deprecated in Go 1.16 and SFTPGo is an application, not
a library, we have no reason to keep compatibility with old Go
versions.

Go 1.16 fix some cifs related issues too.
This commit is contained in:
Nicola Murino
2021-02-25 21:53:04 +01:00
parent 4b2edff6dd
commit ca3e15578e
37 changed files with 211 additions and 232 deletions

View File

@@ -4,7 +4,7 @@ import (
"errors"
"fmt"
"html/template"
"io/ioutil"
"io"
"net/http"
"net/url"
"path"
@@ -708,7 +708,7 @@ func getGCSConfig(r *http.Request) (vfs.GCSFsConfig, error) {
return config, err
}
defer credentials.Close()
fileBytes, err := ioutil.ReadAll(credentials)
fileBytes, err := io.ReadAll(credentials)
if err != nil || len(fileBytes) == 0 {
if len(fileBytes) == 0 {
err = errors.New("credentials file size must be greater than 0")
@@ -1063,7 +1063,7 @@ func handleWebRestore(w http.ResponseWriter, r *http.Request) {
}
defer backupFile.Close()
backupContent, err := ioutil.ReadAll(backupFile)
backupContent, err := io.ReadAll(backupFile)
if err != nil || len(backupContent) == 0 {
if len(backupContent) == 0 {
err = errors.New("backup file size must be greater than 0")