Merge pull request #1846 from filecoin-project/feat/trim-token-file

cli: Trim spaces from token file
This commit is contained in:
Whyrusleeping
2020-05-27 10:58:09 -07:00
committed by GitHub
+9 -2
View File
@@ -1,9 +1,9 @@
package repo
import (
"bytes"
"encoding/json"
"fmt"
"github.com/filecoin-project/sector-storage/stores"
"io"
"io/ioutil"
"os"
@@ -21,6 +21,8 @@ import (
"github.com/multiformats/go-multiaddr"
"golang.org/x/xerrors"
"github.com/filecoin-project/sector-storage/stores"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/config"
)
@@ -191,7 +193,12 @@ func (fsr *FsRepo) APIToken() ([]byte, error) {
}
defer f.Close() //nolint: errcheck // Read only op
return ioutil.ReadAll(f)
tb, err := ioutil.ReadAll(f)
if err != nil {
return nil, err
}
return bytes.TrimSpace(tb), nil
}
// Lock acquires exclusive lock on this repo