wisski-cloud-distillery/internal/wisski/ingredient/locker/locked.go
2022-11-18 08:40:44 +01:00

24 lines
661 B
Go

package locker
import (
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/internal/status"
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
)
// Locked checks if this WissKI is currently locked.
func (lock *Locker) Locked() (locked bool) {
table, err := lock.SQL.QueryTable(true, models.LockTable)
if err != nil {
return false
}
// check if this instance is locked
table.Select("count(*) > 0").Where("slug = ?", lock.Slug).Find(&locked)
return
}
func (locker *Locker) Fetch(flags ingredient.FetcherFlags, info *status.Information) (err error) {
info.Locked = locker.Locked()
return
}