continue unfinished syncs
This commit is contained in:
parent
6a09ae5546
commit
27c5db03fb
1 changed files with 43 additions and 35 deletions
24
ytsync.go
24
ytsync.go
|
@ -134,9 +134,21 @@ func (s *Sync) CountVideos() (uint64, error) {
|
|||
}
|
||||
|
||||
func (s *Sync) FullCycle() error {
|
||||
if os.Getenv("HOME") == "" {
|
||||
return errors.New("no $HOME env var found")
|
||||
}
|
||||
|
||||
newChannel := true
|
||||
|
||||
lbryumDir := os.Getenv("HOME") + "/.lbryum"
|
||||
walletDir := os.Getenv("HOME") + "/wallets/" + strings.Replace(s.LbryChannelName, "@", "", 1)
|
||||
if _, err := os.Stat(walletDir); !os.IsNotExist(err) {
|
||||
return errors.New("channel has already been uploaded, and wallet is in " + walletDir)
|
||||
newChannel = false
|
||||
err = os.Rename(walletDir, lbryumDir)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, 0)
|
||||
}
|
||||
log.Println("Continuing previous upload")
|
||||
}
|
||||
|
||||
err := s.startDaemonViaSystemd()
|
||||
|
@ -144,6 +156,7 @@ func (s *Sync) FullCycle() error {
|
|||
return err
|
||||
}
|
||||
|
||||
if newChannel {
|
||||
s.initDaemon()
|
||||
|
||||
addressResp, err := s.daemon.WalletUnusedAddress()
|
||||
|
@ -177,6 +190,7 @@ func (s *Sync) FullCycle() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = s.Go()
|
||||
if err != nil {
|
||||
|
@ -184,7 +198,7 @@ func (s *Sync) FullCycle() error {
|
|||
}
|
||||
|
||||
// wait for reflection to finish???
|
||||
wait = 15 * time.Second // should bump this up to a few min, but keeping it low for testing
|
||||
wait := 15 * time.Second // should bump this up to a few min, but keeping it low for testing
|
||||
log.Println("Waiting " + wait.String() + " to finish reflecting everything")
|
||||
time.Sleep(wait)
|
||||
|
||||
|
@ -194,12 +208,6 @@ func (s *Sync) FullCycle() error {
|
|||
return err
|
||||
}
|
||||
|
||||
// move wallet
|
||||
if os.Getenv("HOME") == "" {
|
||||
return errors.New("could not move lbryum dir - no $HOME var found")
|
||||
}
|
||||
|
||||
lbryumDir := os.Getenv("HOME") + "/.lbryum"
|
||||
err = os.Rename(lbryumDir, walletDir)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, 0)
|
||||
|
|
Loading…
Reference in a new issue