Commit 654a27cf authored by ci's avatar ci
Browse files

fix env parsing

handle unhandled error
parent ca176c4d
......@@ -102,7 +102,10 @@ const (
func (s *SyncManager) Start() error {
if logUtils.IsCleanOnStartup() {
logUtils.CleanForStartup()
err := logUtils.CleanForStartup()
if err != nil {
return err
}
}
syncCount := 0
......
......@@ -4,7 +4,6 @@ import (
"fmt"
"math"
"net/http"
"os"
"strconv"
"time"
......@@ -27,7 +26,7 @@ func (s *Sync) enableAddressReuse() error {
return errors.Err(err)
}
accounts := accountsResponse.LBCMainnet
if os.Getenv("REGTEST") == "true" {
if logUtils.IsRegTest() {
accounts = accountsResponse.LBCRegtest
}
for _, a := range accounts {
......@@ -141,7 +140,7 @@ func (s *Sync) ensureEnoughUTXOs() error {
return errors.Err(err)
}
accountsNet := (*accounts).LBCMainnet
if os.Getenv("REGTEST") == "true" {
if logUtils.IsRegTest() {
accountsNet = (*accounts).LBCRegtest
}
defaultAccount := ""
......
......@@ -171,7 +171,7 @@ func (s *Sync) getWalletPaths() (defaultWallet, tempWallet string, key *string,
defaultWallet = os.Getenv("HOME") + "/.lbryum/wallets/default_wallet"
tempWallet = os.Getenv("HOME") + "/.lbryum/wallets/tmp_wallet"
key = aws.String("/wallets/" + s.YoutubeChannelID)
if os.Getenv("REGTEST") == "true" {
if logUtils.IsRegTest() {
defaultWallet = os.Getenv("HOME") + "/.lbryum_regtest/wallets/default_wallet"
tempWallet = os.Getenv("HOME") + "/.lbryum_regtest/wallets/tmp_wallet"
key = aws.String("/regtest/" + s.YoutubeChannelID)
......@@ -192,7 +192,7 @@ func (s *Sync) getWalletPaths() (defaultWallet, tempWallet string, key *string,
func (s *Sync) uploadWallet() error {
defaultWalletDir := logUtils.GetDefaultWalletPath()
key := aws.String("/wallets/" + s.YoutubeChannelID)
if os.Getenv("REGTEST") == "true" {
if logUtils.IsRegTest() {
key = aws.String("/regtest/" + s.YoutubeChannelID)
}
......
......@@ -7,6 +7,7 @@ import (
"os/exec"
"os/user"
"path/filepath"
"strconv"
"github.com/lbryio/lbry.go/extras/errors"
"github.com/lbryio/lbry.go/lbrycrd"
......@@ -81,11 +82,19 @@ func getDockerContainer(name string, all bool) (*types.Container, error) {
}
func IsUsingDocker() bool {
return os.Getenv("LBRYNET_USE_DOCKER") == "true"
useDocker, err := strconv.ParseBool(os.Getenv("LBRYNET_USE_DOCKER"))
if err != nil {
return false
}
return useDocker
}
func IsRegTest() bool {
return os.Getenv("REGTEST") == "true"
usesRegtest, err := strconv.ParseBool(os.Getenv("REGTEST"))
if err != nil {
return false
}
return usesRegtest
}
func GetLbrycrdClient(lbrycrdString string) (*lbrycrd.Client, error) {
......@@ -107,7 +116,11 @@ func GetLbrycrdClient(lbrycrdString string) (*lbrycrd.Client, error) {
}
func IsCleanOnStartup() bool {
return os.Getenv("CLEAN_ON_STARTUP") == "true"
shouldClean, err := strconv.ParseBool(os.Getenv("CLEAN_ON_STARTUP"))
if err != nil {
return false
}
return shouldClean
}
func IsLbrynetRunning() (bool, error) {
......@@ -279,7 +292,7 @@ func stopDaemonViaSystemd() error {
func GetDefaultWalletPath() string {
defaultWalletDir := os.Getenv("HOME") + "/.lbryum/wallets/default_wallet"
if os.Getenv("REGTEST") == "true" {
if IsRegTest() {
defaultWalletDir = os.Getenv("HOME") + "/.lbryum_regtest/wallets/default_wallet"
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment