Require access to Still via method

This commit adds a safeguard to accessing the still from a specific
component by requiring access via the component.GetStill method.
This commit is contained in:
Tom Wiesing 2024-04-08 22:39:32 +02:00
parent 81fa84c244
commit 8235ea9105
No known key found for this signature in database
63 changed files with 288 additions and 197 deletions

View file

@ -10,13 +10,15 @@ import (
// Locked checks if this WissKI is currently locked.
// If an error occurs, the instance is considered not locked.
func (lock *Locker) Locked(ctx context.Context) (locked bool) {
table, err := lock.Malt.SQL.QueryTable(ctx, lock.Malt.LockTable)
liquid := ingredient.GetLiquid(lock)
table, err := liquid.SQL.QueryTable(ctx, liquid.LockTable)
if err != nil {
return false
}
// check if this instance is locked
table.Select("count(*) > 0").Where("slug = ?", lock.Slug).Find(&locked)
table.Select("count(*) > 0").Where("slug = ?", liquid.Slug).Find(&locked)
return
}