polling on file changes should work now

This commit is contained in:
Robin Olsen
2026-04-03 14:03:45 +02:00
parent bf8ea6103e
commit b2686ea602
2 changed files with 54 additions and 1 deletions

View File

@@ -104,10 +104,34 @@ func (t *CodingTask) Setup(ctx context.Context) error {
return err
}
go func() {
ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()
lastMod := t.lastModified
for {
select {
case <-ticker.C:
if stat, err := os.Stat("./code.txt"); err == nil {
if stat.ModTime().After(lastMod) {
lastMod = stat.ModTime()
if t.app.SubmitChan != nil {
select {
case t.app.SubmitChan <- models.ValidationTrigger{Source: models.ValidationTriggerAutoPoll}:
default:
}
}
}
}
case <-ctx.Done():
return
}
}
}()
return nil
}
func (t *CodingTask) Validate(ctx context.Context) ValidationFeedback {
expect := check.NewExpector()

View File

@@ -104,6 +104,35 @@ func (t *GitTask) Setup(ctx context.Context) error {
return err
}
go func() {
ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()
var lastMod time.Time
if stat, err := os.Stat("./task/.git/index"); err == nil {
lastMod = stat.ModTime()
}
for {
select {
case <-ticker.C:
if stat, err := os.Stat("./task/.git/index"); err == nil {
if stat.ModTime().After(lastMod) {
lastMod = stat.ModTime()
if t.app.SubmitChan != nil {
select {
case t.app.SubmitChan <- models.ValidationTrigger{Source: models.ValidationTriggerAutoPoll}:
default:
}
}
}
}
case <-ctx.Done():
return
}
}
}()
return nil
}