move wallet file, not the whole dir
This commit is contained in:
parent
b7b375dc83
commit
8f3070e13e
1 changed files with 17 additions and 5 deletions
22
ytsync.go
22
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,12 +148,16 @@ func (s *Sync) FullCycle() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
newChannel := true
|
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
|
newChannel = false
|
||||||
err = os.Rename(walletDir, lbryumDir)
|
err = os.Rename(walletBackupDir, defaultWalletDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, 0)
|
return errors.Wrap(err, 0)
|
||||||
}
|
}
|
||||||
|
@ -210,7 +222,7 @@ func (s *Sync) FullCycle() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.Rename(lbryumDir, walletDir)
|
err = os.Rename(defaultWalletDir, walletBackupDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, 0)
|
return errors.Wrap(err, 0)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue