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
commit 8544bda14a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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