From c76ba11dc4ae23ab17115b87d0d2b9711ffdbf01 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 28 Sep 2024 12:08:58 +0300 Subject: fix this --- internal/schedule/schedule.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'internal/schedule') diff --git a/internal/schedule/schedule.go b/internal/schedule/schedule.go index d8b7143..82afc18 100644 --- a/internal/schedule/schedule.go +++ b/internal/schedule/schedule.go @@ -11,7 +11,10 @@ import ( "codeberg.org/snonux/gos/internal/oi" ) -var NothingToSchedule = errors.New("nothing to schedule") +var ( + ErrNothingToSchedule = errors.New("nothing to schedule") + ErrNothingQueued = errors.New("nothing queued") +) func Run(args config.Args, platform string) (string, error) { dir := fmt.Sprintf("%s/db/platforms/%s", args.GosDir, strings.ToLower(platform)) @@ -23,11 +26,17 @@ func Run(args config.Args, platform string) (string, error) { log.Println("For", platform, "stats:", stats) if stats.targetHit() { log.Println("Target hit, not posting at", platform) - return "", NothingToSchedule + return "", ErrNothingToSchedule } // Schedule random qeued entry for platform - return oi.ReadDirRandomEntry(dir, func(file os.DirEntry) bool { + randomEntry, err := oi.ReadDirRandomEntry(dir, func(file os.DirEntry) bool { return strings.HasSuffix(file.Name(), ".queued") }) + + if err != nil { + // TODO: FIX THIS + return randomEntry, fmt.Errorf("%w: %w", ErrNothingQueued, err) + } + return randomEntry, nil } -- cgit v1.2.3