Skip to content

Commit

Permalink
replaced outdated os to ioutils methods
Browse files Browse the repository at this point in the history
  • Loading branch information
avendauz committed Aug 4, 2021
1 parent b487f79 commit ca206ce
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions x/curium/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"github.com/bluzelle/curium/app/ante/gasmeter"
devel "github.com/bluzelle/curium/types"
"io/ioutil"

cryptoKeys "github.com/cosmos/cosmos-sdk/crypto/keys"

Expand All @@ -24,7 +25,6 @@ import (
"github.com/tendermint/tendermint/rpc/core"
coretypes "github.com/tendermint/tendermint/rpc/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
"io"
"net/http"
"regexp"

Expand Down Expand Up @@ -342,6 +342,6 @@ func httpGet(url string) ([]byte, error) {
return nil, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
body, err := ioutil.ReadAll(resp.Body)
return body, err
}
4 changes: 3 additions & 1 deletion x/nft/client/rest/getNftByVendorHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import (
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/gorilla/mux"
"io"
"io/ioutil"
"net/http"
"os"

)

func getNftByVendorHandler(clientCtx context.CLIContext) http.HandlerFunc {
Expand All @@ -33,7 +35,7 @@ func getNftByVendorHandler(clientCtx context.CLIContext) http.HandlerFunc {

var info map[string]interface{}

infoBytes, err := os.ReadFile(infoLocation)
infoBytes, err := ioutil.ReadFile(infoLocation)
if err != nil {
rest.WriteErrorResponse(w, http.StatusNotFound, "Unable to read info file")
}
Expand Down
3 changes: 2 additions & 1 deletion x/nft/client/rest/getNftHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/gorilla/mux"
"io"
"io/ioutil"
"net/http"
"os"
)
Expand All @@ -30,7 +31,7 @@ func getNftHandler(clientCtx context.CLIContext) http.HandlerFunc {

var info map[string]interface{}

infoBytes, err := os.ReadFile(infoLocation)
infoBytes, err := ioutil.ReadFile(infoLocation)
if err != nil {
rest.WriteErrorResponse(w, http.StatusNotFound, "Unable to read info file")
}
Expand Down
5 changes: 3 additions & 2 deletions x/nft/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/zeebo/bencode"
"io/ioutil"
"os"
)

Expand Down Expand Up @@ -47,7 +48,7 @@ func handleMsgCreateNft(goCtx sdk.Context, k keeper.Keeper, msg *types.MsgCreate


if _, err := os.Stat(k.HomeDir+"/nft/"+msg.Hash); err == nil {
metainfo, err := k.BtClient.TorrentFromFile(msg.Hash, msg.Vendor)
metainfo, err := k.BtClient.TorrentFromFile(msg.Hash)
if err != nil {
return nil, sdkerrors.New("nft", 2, fmt.Sprintf("unable to create torrent for file", msg.Hash))
}
Expand Down Expand Up @@ -99,7 +100,7 @@ func handleMsgPublishFile(ctx sdk.Context, k Keeper, msg *types.MsgPublishFile)
UserId: msg.UserId,
Mime: msg.Mime,
}
err = os.WriteFile(k.HomeDir+"/nft/"+msg.Hash+".info", k.Cdc.MustMarshalJSON(&info), 0666)
err = ioutil.WriteFile(k.HomeDir+"/nft/"+msg.Hash+".info", k.Cdc.MustMarshalJSON(&info), 0666)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion x/nft/keeper/createNft.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/bluzelle/curium/x/nft/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/zeebo/bencode"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -82,7 +83,7 @@ func (k Keeper) AssembleNftFile(uploadDir string, nftDir string, msg *types.MsgC
if err == nil && uploadRegEx.MatchString(info.Name()) {
fmt.Println(path)
if path != uploadDir {
data, err := os.ReadFile(path)
data, err := ioutil.ReadFile(path)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion x/torrentClient/TorrentClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (tc *TorrentClient) RetrieveFile(metaInfo *metainfo.MetaInfo) {
}()
}

func (tc TorrentClient) TorrentFromFile(filePath string, vendor string) (*metainfo.MetaInfo, error) {
func (tc TorrentClient) TorrentFromFile(filePath string) (*metainfo.MetaInfo, error) {
private := true
info := metainfo.Info{
PieceLength: PIECE_SIZE * 1024,
Expand Down

0 comments on commit ca206ce

Please sign in to comment.