remove invalid tests
move functions out of utils address review comments revert lockfile changes
This commit is contained in:
parent
453ba5450b
commit
e0ec334af9
4 changed files with 24 additions and 36 deletions
21
manager.go
21
manager.go
|
@ -12,6 +12,8 @@ import (
|
||||||
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/lbryio/lbry.go/errors"
|
"github.com/lbryio/lbry.go/errors"
|
||||||
"github.com/lbryio/lbry.go/null"
|
"github.com/lbryio/lbry.go/null"
|
||||||
"github.com/lbryio/lbry.go/util"
|
"github.com/lbryio/lbry.go/util"
|
||||||
|
@ -214,7 +216,7 @@ func (s SyncManager) Start() error {
|
||||||
"NotEnoughFunds",
|
"NotEnoughFunds",
|
||||||
"no space left on device",
|
"no space left on device",
|
||||||
}
|
}
|
||||||
if util.InSliceContains(err.Error(), fatalErrors) {
|
if util.ContainedInSlice(err.Error(), fatalErrors) {
|
||||||
return errors.Prefix("@Nikooo777 this requires manual intervention! Exiting...", err)
|
return errors.Prefix("@Nikooo777 this requires manual intervention! Exiting...", err)
|
||||||
}
|
}
|
||||||
util.SendInfoToSlack("A non fatal error was reported by the sync process. %s\nContinuing...", err.Error())
|
util.SendInfoToSlack("A non fatal error was reported by the sync process. %s\nContinuing...", err.Error())
|
||||||
|
@ -243,7 +245,7 @@ func (s SyncManager) checkUsedSpace() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
usedPctile, err := util.GetUsedSpace(usr.HomeDir + "/.lbrynet/blobfiles/")
|
usedPctile, err := GetUsedSpace(usr.HomeDir + "/.lbrynet/blobfiles/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -253,3 +255,18 @@ func (s SyncManager) checkUsedSpace() error {
|
||||||
util.SendInfoToSlack("disk usage: %.1f%%", usedPctile*100)
|
util.SendInfoToSlack("disk usage: %.1f%%", usedPctile*100)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUsedSpace returns a value between 0 and 1, with 0 being completely empty and 1 being full, for the disk that holds the provided path
|
||||||
|
func GetUsedSpace(path string) (float32, error) {
|
||||||
|
var stat syscall.Statfs_t
|
||||||
|
err := syscall.Statfs(path, &stat)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
// Available blocks * size per block = available space in bytes
|
||||||
|
all := stat.Blocks * uint64(stat.Bsize)
|
||||||
|
free := stat.Bfree * uint64(stat.Bsize)
|
||||||
|
used := all - free
|
||||||
|
|
||||||
|
return float32(used) / float32(all), nil
|
||||||
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ func (v YoutubeVideo) delete() error {
|
||||||
videoPath := v.getFilename()
|
videoPath := v.getFilename()
|
||||||
err := os.Remove(videoPath)
|
err := os.Remove(videoPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugln(errors.Prefix("delete error", err))
|
log.Errorln(errors.Prefix("delete error", err))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Debugln(v.id + " deleted from disk (" + videoPath + ")")
|
log.Debugln(v.id + " deleted from disk (" + videoPath + ")")
|
||||||
|
|
11
ytsync.go
11
ytsync.go
|
@ -100,7 +100,7 @@ func (s *Sync) FullCycle() (e error) {
|
||||||
noFailConditions := []string{
|
noFailConditions := []string{
|
||||||
"this youtube channel is being managed by another server",
|
"this youtube channel is being managed by another server",
|
||||||
}
|
}
|
||||||
if util.InSliceContains(e.Error(), noFailConditions) {
|
if util.ContainedInSlice(e.Error(), noFailConditions) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := s.Manager.setChannelSyncStatus(s.YoutubeChannelID, StatusFailed)
|
err := s.Manager.setChannelSyncStatus(s.YoutubeChannelID, StatusFailed)
|
||||||
|
@ -219,7 +219,7 @@ func (s *Sync) doSync() error {
|
||||||
|
|
||||||
err = s.walletSetup()
|
err = s.walletSetup()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Err("Initial wallet setup failed! Manual Intervention is required. Reason: %v", err)
|
return errors.Prefix("Initial wallet setup failed! Manual Intervention is required.", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.StopOnError {
|
if s.StopOnError {
|
||||||
|
@ -281,7 +281,7 @@ func (s *Sync) startWorker(workerNum int) {
|
||||||
"NotEnoughFunds",
|
"NotEnoughFunds",
|
||||||
"Cannot publish using channel",
|
"Cannot publish using channel",
|
||||||
}
|
}
|
||||||
if util.InSliceContains(err.Error(), fatalErrors) || s.StopOnError {
|
if util.ContainedInSlice(err.Error(), fatalErrors) || s.StopOnError {
|
||||||
s.grp.Stop()
|
s.grp.Stop()
|
||||||
} else if s.MaxTries > 1 {
|
} else if s.MaxTries > 1 {
|
||||||
errorsNoRetry := []string{
|
errorsNoRetry := []string{
|
||||||
|
@ -296,7 +296,7 @@ func (s *Sync) startWorker(workerNum int) {
|
||||||
"Client.Timeout exceeded while awaiting headers)",
|
"Client.Timeout exceeded while awaiting headers)",
|
||||||
"video is bigger than 2GB, skipping for now",
|
"video is bigger than 2GB, skipping for now",
|
||||||
}
|
}
|
||||||
if util.InSliceContains(err.Error(), errorsNoRetry) {
|
if util.ContainedInSlice(err.Error(), errorsNoRetry) {
|
||||||
log.Println("This error should not be retried at all")
|
log.Println("This error should not be retried at all")
|
||||||
} else if tryCount < s.MaxTries {
|
} else if tryCount < s.MaxTries {
|
||||||
if strings.Contains(err.Error(), "txn-mempool-conflict") ||
|
if strings.Contains(err.Error(), "txn-mempool-conflict") ||
|
||||||
|
@ -369,9 +369,6 @@ func (s *Sync) enqueueYoutubeVideos() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range playlistResponse.Items {
|
for _, item := range playlistResponse.Items {
|
||||||
// todo: there's thumbnail info here. why did we need lambda???
|
|
||||||
// because when videos are taken down from youtube, the thumb is gone too
|
|
||||||
|
|
||||||
// normally we'd send the video into the channel here, but youtube api doesn't have sorting
|
// normally we'd send the video into the channel here, but youtube api doesn't have sorting
|
||||||
// so we have to get ALL the videos, then sort them, then send them in
|
// so we have to get ALL the videos, then sort them, then send them in
|
||||||
videos = append(videos, sources.NewYoutubeVideo(s.videoDirectory, item.Snippet))
|
videos = append(videos, sources.NewYoutubeVideo(s.videoDirectory, item.Snippet))
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package ytsync
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestWaitForDaemonProcess(t *testing.T) {
|
|
||||||
/*
|
|
||||||
err := startDaemonViaSystemd()
|
|
||||||
if err != nil {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
log.Infoln("Waiting 5 seconds for the daemon to start...")
|
|
||||||
time.Sleep(5 * time.Second)
|
|
||||||
err = stopDaemonViaSystemd()
|
|
||||||
if err != nil {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//start lbrynet before running this test
|
|
||||||
// stop lbrynet while running this test
|
|
||||||
err := waitForDaemonProcess(100)
|
|
||||||
if err != nil {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue