diff --git a/server/common/config_state.go b/server/common/config_state.go index a3ed45f0..540f1a6a 100644 --- a/server/common/config_state.go +++ b/server/common/config_state.go @@ -17,7 +17,7 @@ import ( "fmt" "github.com/tidwall/gjson" "github.com/tidwall/sjson" - "io/ioutil" + "io" "os" ) @@ -44,7 +44,7 @@ func LoadConfig() ([]byte, error) { } return nil, err } - cFile, err := ioutil.ReadAll(file) + cFile, err := io.ReadAll(file) file.Close() if err != nil { return nil, err diff --git a/server/common/crypto.go b/server/common/crypto.go index 2ac22227..70581920 100644 --- a/server/common/crypto.go +++ b/server/common/crypto.go @@ -11,7 +11,6 @@ import ( "encoding/hex" "hash/fnv" "io" - "io/ioutil" "math/big" mathrand "math/rand" "os" @@ -179,7 +178,7 @@ func decompress(something []byte) ([]byte, error) { return []byte(""), nil } r.Close() - return ioutil.ReadAll(r) + return io.ReadAll(r) } func sign(something []byte) ([]byte, error) { diff --git a/server/common/ssl/cert.go b/server/common/ssl/cert.go index 2de762da..0642f0ba 100644 --- a/server/common/ssl/cert.go +++ b/server/common/ssl/cert.go @@ -5,7 +5,7 @@ import ( "crypto/rsa" "crypto/x509" "encoding/pem" - "io/ioutil" + "io" "os" ) @@ -45,7 +45,7 @@ func pullCertificateFromFS() (*x509.Certificate, []byte, error) { return nil, nil, err } defer file.Close() - certPEM, err := ioutil.ReadAll(file) + certPEM, err := io.ReadAll(file) if err != nil { return nil, nil, err } diff --git a/server/common/ssl/private.go b/server/common/ssl/private.go index 27d079aa..77d59fc5 100644 --- a/server/common/ssl/private.go +++ b/server/common/ssl/private.go @@ -5,7 +5,7 @@ import ( "crypto/rsa" "crypto/x509" "encoding/pem" - "io/ioutil" + "io" "os" ) @@ -43,7 +43,7 @@ func pullPrivateKeyFromFS() (*rsa.PrivateKey, []byte, error) { } defer file.Close() - keyPEM, err := ioutil.ReadAll(file) + keyPEM, err := io.ReadAll(file) if err != nil { return nil, nil, err } diff --git a/server/common/utils.go b/server/common/utils.go index d1325b51..70d9142f 100644 --- a/server/common/utils.go +++ b/server/common/utils.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "strconv" "strings" ) @@ -78,11 +77,11 @@ func NewStringFromInterface(val interface{}) string { } func NewReadCloserFromBytes(t []byte) io.ReadCloser { - return ioutil.NopCloser(bytes.NewReader(t)) + return io.NopCloser(bytes.NewReader(t)) } func NewReadCloserFromReader(r io.Reader) io.ReadCloser { - return ioutil.NopCloser(r) + return io.NopCloser(r) } func PrettyPrint(json_dirty []byte) []byte { diff --git a/server/ctrl/admin.go b/server/ctrl/admin.go index ed266130..8ca9eeb3 100644 --- a/server/ctrl/admin.go +++ b/server/ctrl/admin.go @@ -5,7 +5,6 @@ import ( . "github.com/mickael-kerjean/filestash/server/common" "golang.org/x/crypto/bcrypt" "io" - "io/ioutil" "net/http" "os" "strconv" @@ -56,7 +55,7 @@ func AdminSessionAuthenticate(ctx *App, res http.ResponseWriter, req *http.Reque return } var params map[string]string - b, _ := ioutil.ReadAll(req.Body) + b, _ := io.ReadAll(req.Body) json.Unmarshal(b, ¶ms) if err := bcrypt.CompareHashAndPassword([]byte(admin), []byte(params["password"])); err != nil { SendErrorResult(res, ErrInvalidPassword) diff --git a/server/ctrl/config.go b/server/ctrl/config.go index 091da4c6..f6797cbd 100644 --- a/server/ctrl/config.go +++ b/server/ctrl/config.go @@ -2,7 +2,7 @@ package ctrl import ( . "github.com/mickael-kerjean/filestash/server/common" - "io/ioutil" + "io" "net/http" ) @@ -13,7 +13,7 @@ func PrivateConfigHandler(ctx *App, res http.ResponseWriter, req *http.Request) } func PrivateConfigUpdateHandler(ctx *App, res http.ResponseWriter, req *http.Request) { - b, _ := ioutil.ReadAll(req.Body) + b, _ := io.ReadAll(req.Body) if err := SaveConfig(b); err != nil { SendErrorResult(res, err) return diff --git a/server/generator/emacs-el.go b/server/generator/emacs-el.go index 213baff4..9198a97b 100644 --- a/server/generator/emacs-el.go +++ b/server/generator/emacs-el.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "io/ioutil" + "io" "os" ) @@ -15,7 +15,7 @@ func main() { } defer f.Close() - j, err := ioutil.ReadAll(f) + j, err := io.ReadAll(f) if err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) os.Exit(1) diff --git a/server/generator/mime.go b/server/generator/mime.go index 3e8e18fb..b29d822f 100644 --- a/server/generator/mime.go +++ b/server/generator/mime.go @@ -3,7 +3,7 @@ package main import ( "encoding/json" "fmt" - "io/ioutil" + "io" "os" ) @@ -16,7 +16,7 @@ func main() { } defer f.Close() - j, err := ioutil.ReadAll(f) + j, err := io.ReadAll(f) if err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) os.Exit(1) diff --git a/server/middleware/context.go b/server/middleware/context.go index cb76b5cd..2d2daa37 100644 --- a/server/middleware/context.go +++ b/server/middleware/context.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" . "github.com/mickael-kerjean/filestash/server/common" - "io/ioutil" + "io" "net/http" "strings" ) @@ -12,7 +12,7 @@ import ( func BodyParser(fn HandlerFunc) HandlerFunc { extractBody := func(req *http.Request) (map[string]interface{}, error) { body := map[string]interface{}{} - byt, err := ioutil.ReadAll(req.Body) + byt, err := io.ReadAll(req.Body) if err != nil { return body, err } diff --git a/server/plugin/plg_backend_artifactory/index.go b/server/plugin/plg_backend_artifactory/index.go index 8a2d08ec..0ef2bbb5 100644 --- a/server/plugin/plg_backend_artifactory/index.go +++ b/server/plugin/plg_backend_artifactory/index.go @@ -6,7 +6,6 @@ import ( "fmt" . "github.com/mickael-kerjean/filestash/server/common" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -162,7 +161,7 @@ func (this ArtifactoryStorage) Ls(path string) ([]os.FileInfo, error) { if err != nil { return nil, err } - jsonStr, err := ioutil.ReadAll(res.Body) + jsonStr, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { Log.Debug("plg_backend_artifactory::ls readall data[%s] status[%d]", string(jsonStr), res.StatusCode) @@ -190,7 +189,7 @@ func (this ArtifactoryStorage) Cat(path string) (io.ReadCloser, error) { if err != nil { return nil, err } - jsonStr, err := ioutil.ReadAll(res.Body) + jsonStr, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { Log.Debug("plg_backend_artifactory::cat readall data[%s] status[%d]", string(jsonStr), res.StatusCode) @@ -269,7 +268,7 @@ func (this ArtifactoryStorage) Mkdir(path string) error { if err != nil { return err } - jsonStr, err := ioutil.ReadAll(res.Body) + jsonStr, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { Log.Debug("plg_backend_artifactory::mkdir readall status[%d] data[%s]", res.StatusCode, string(jsonStr)) @@ -307,7 +306,7 @@ func (this ArtifactoryStorage) Rm(path string) error { if err != nil { return err } - jsonStr, err := ioutil.ReadAll(res.Body) + jsonStr, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { Log.Debug("plg_backend_artifactory::rm readall status[%d] data[%s]", res.StatusCode, string(jsonStr)) @@ -336,7 +335,7 @@ func (this ArtifactoryStorage) Mv(from, to string) error { if err != nil { return err } - jsonStr, err := ioutil.ReadAll(res.Body) + jsonStr, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { Log.Debug("plg_backend_artifactory::mv readall status[%d] data[%s]", res.StatusCode, string(jsonStr)) @@ -367,7 +366,7 @@ func (this ArtifactoryStorage) Save(path string, content io.Reader) error { if err != nil { return err } - jsonStr, err := ioutil.ReadAll(res.Body) + jsonStr, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { Log.Debug("plg_backend_artifactory::save readall status[%d] data[%s]", res.StatusCode, string(jsonStr)) diff --git a/server/plugin/plg_backend_backblaze/index.go b/server/plugin/plg_backend_backblaze/index.go index 93357402..bfe3cee9 100644 --- a/server/plugin/plg_backend_backblaze/index.go +++ b/server/plugin/plg_backend_backblaze/index.go @@ -7,7 +7,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -56,7 +55,7 @@ func (this Backblaze) Init(params map[string]string, app *App) (IBackend, error) if err != nil { return nil, err } - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { return nil, err @@ -79,7 +78,7 @@ func (this Backblaze) Init(params map[string]string, app *App) (IBackend, error) if err != nil { return nil, err } - body, err = ioutil.ReadAll(res.Body) + body, err = io.ReadAll(res.Body) res.Body.Close() if err != nil { return nil, err @@ -153,7 +152,7 @@ func (this Backblaze) Ls(path string) ([]os.FileInfo, error) { if err != nil { return nil, err } - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { return nil, err @@ -222,7 +221,7 @@ func (this Backblaze) Mkdir(path string) error { if err != nil { return err } - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { return err @@ -260,7 +259,7 @@ func (this Backblaze) Rm(path string) error { if err != nil { return err } - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { return err @@ -289,7 +288,7 @@ func (this Backblaze) Rm(path string) error { if err != nil { return err } - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { return err @@ -317,7 +316,7 @@ func (this Backblaze) Rm(path string) error { if err != nil { return err } - if body, err = ioutil.ReadAll(res.Body); err != nil { + if body, err = io.ReadAll(res.Body); err != nil { return err } res.Body.Close() @@ -349,7 +348,7 @@ func (this Backblaze) Touch(path string) error { if err != nil { return err } - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { return err @@ -378,7 +377,7 @@ func (this Backblaze) Touch(path string) error { if err != nil { return err } - body, err = ioutil.ReadAll(res.Body) + body, err = io.ReadAll(res.Body) res.Body.Close() if err != nil { return err @@ -406,7 +405,7 @@ func (this Backblaze) Save(path string, file io.Reader) error { if err != nil { return err } - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) res.Body.Close() if err != nil { return err @@ -468,7 +467,7 @@ func (this Backblaze) Save(path string, file io.Reader) error { if err != nil { return err } - body, err = ioutil.ReadAll(res.Body) + body, err = io.ReadAll(res.Body) res.Body.Close() if err != nil { return err diff --git a/server/plugin/plg_backend_dav/index.go b/server/plugin/plg_backend_dav/index.go index 87469794..da43096d 100644 --- a/server/plugin/plg_backend_dav/index.go +++ b/server/plugin/plg_backend_dav/index.go @@ -5,7 +5,6 @@ import ( "fmt" . "github.com/mickael-kerjean/filestash/server/common" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -201,7 +200,7 @@ func (this Dav) Mv(from string, to string) error { if err != nil { return err } - d, err := ioutil.ReadAll(reader) + d, err := io.ReadAll(reader) if err != nil { return ErrNotValid } diff --git a/server/plugin/plg_backend_dropbox/index.go b/server/plugin/plg_backend_dropbox/index.go index cda4f156..e26d5be5 100644 --- a/server/plugin/plg_backend_dropbox/index.go +++ b/server/plugin/plg_backend_dropbox/index.go @@ -4,7 +4,6 @@ import ( "encoding/json" . "github.com/mickael-kerjean/filestash/server/common" "io" - "io/ioutil" "net/http" "os" "path/filepath" @@ -123,7 +122,7 @@ func (d Dropbox) Cat(path string) (io.ReadCloser, error) { arg := struct { Path string `json:"path"` }{d.path(path)} - json, _ := ioutil.ReadAll(d.toReader(arg)) + json, _ := io.ReadAll(d.toReader(arg)) req.Header.Set("Dropbox-API-Arg", string(json)) }) if err != nil { @@ -184,7 +183,7 @@ func (d Dropbox) Save(path string, file io.Reader) error { AutoRename bool `json:"autorename"` Mode string `json:"mode"` }{d.path(path), false, "overwrite"} - json, _ := ioutil.ReadAll(d.toReader(arg)) + json, _ := io.ReadAll(d.toReader(arg)) req.Header.Set("Dropbox-API-Arg", string(json)) req.Header.Set("Content-Type", "application/octet-stream") }) diff --git a/server/plugin/plg_image_bimg/index.go b/server/plugin/plg_image_bimg/index.go index 08d73493..29055c88 100644 --- a/server/plugin/plg_image_bimg/index.go +++ b/server/plugin/plg_image_bimg/index.go @@ -4,7 +4,6 @@ import ( "github.com/h2non/bimg" . "github.com/mickael-kerjean/filestash/server/common" "io" - "io/ioutil" "net/http" ) @@ -28,7 +27,7 @@ func (this thumbnailer) Generate(reader io.ReadCloser, ctx *App, res *http.Respo return reader, nil } - b, err := ioutil.ReadAll(reader) + b, err := io.ReadAll(reader) if err != nil { return reader, err } diff --git a/server/plugin/plg_security_svg/index.go b/server/plugin/plg_security_svg/index.go index 70d7cecf..14743ea2 100644 --- a/server/plugin/plg_security_svg/index.go +++ b/server/plugin/plg_security_svg/index.go @@ -3,7 +3,6 @@ package plg_security_svg import ( . "github.com/mickael-kerjean/filestash/server/common" "io" - "io/ioutil" "net/http" "regexp" ) @@ -42,7 +41,7 @@ func init() { (*res).Header().Set("Content-Security-Policy", "script-src 'none'; default-src 'none'; img-src 'self'") (*res).Header().Set("Content-Type", "text/plain") // XML bomb - txt, _ := ioutil.ReadAll(reader) + txt, _ := io.ReadAll(reader) if regexp.MustCompile("(?is)entity").Match(txt) { txt = []byte("") }