From 8f3070e13e8f1ad24ecdf1c980daed71eed898aa Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Fri, 8 Dec 2017 15:11:44 -0500 Subject: [PATCH] move wallet file, not the whole dir --- ytsync.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ytsync.go b/ytsync.go index 3fcd79c..237abc9 100644 --- a/ytsync.go +++ b/ytsync.go @@ -109,6 +109,14 @@ func (s *Sync) init() error { } } + balance, err := s.daemon.WalletBalance() + if err != nil { + return err + } else if balance == nil { + return errors.New("no response") + } + log.Println("starting with " + decimal.Decimal(*balance).String() + "LBC") + return nil } @@ -140,12 +148,16 @@ func (s *Sync) FullCycle() error { } newChannel := true + defaultWalletDir := os.Getenv("HOME") + "/.lbryum/wallets/default_wallet" + walletBackupDir := os.Getenv("HOME") + "/wallets/" + strings.Replace(s.LbryChannelName, "@", "", 1) + + if _, err := os.Stat(walletBackupDir); !os.IsNotExist(err) { + if _, err := os.Stat(defaultWalletDir); !os.IsNotExist(err) { + return errors.New("Tried to continue previous upload, but default_wallet already exists") + } - lbryumDir := os.Getenv("HOME") + "/.lbryum" - walletDir := os.Getenv("HOME") + "/wallets/" + strings.Replace(s.LbryChannelName, "@", "", 1) - if _, err := os.Stat(walletDir); !os.IsNotExist(err) { newChannel = false - err = os.Rename(walletDir, lbryumDir) + err = os.Rename(walletBackupDir, defaultWalletDir) if err != nil { return errors.Wrap(err, 0) } @@ -210,7 +222,7 @@ func (s *Sync) FullCycle() error { return err } - err = os.Rename(lbryumDir, walletDir) + err = os.Rename(defaultWalletDir, walletBackupDir) if err != nil { return errors.Wrap(err, 0) }