summaryrefslogtreecommitdiff
path: root/internal/schedule
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-09-28 12:08:58 +0300
committerPaul Buetow <paul@buetow.org>2024-09-28 12:08:58 +0300
commitc76ba11dc4ae23ab17115b87d0d2b9711ffdbf01 (patch)
tree86f33c1b22d0fc4be27357cc5f68006bfa8b321a /internal/schedule
parent076c0d5afb299fedc5ee61a13bfec7f86055fc89 (diff)
fix this
Diffstat (limited to 'internal/schedule')
-rw-r--r--internal/schedule/schedule.go15
1 files changed, 12 insertions, 3 deletions
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
}