feat(webui): add state force unlock
All checks were successful
main / main (push) Successful in 2m49s
main / deploy (push) Has been skipped
main / publish (push) Has been skipped

Closes #13
This commit is contained in:
Julien Dessaux 2025-05-02 00:42:50 +02:00
parent 8f17a3661e
commit 20bc9fe17a
Signed by: adyxax
GPG key ID: F92E51B86E07177E
3 changed files with 31 additions and 11 deletions

View file

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"git.adyxax.org/adyxax/tfstated/pkg/model"
"go.n16f.net/uuid"
)
@ -83,4 +84,15 @@ func (db *DB) Unlock(path string, lock any) (bool, error) {
}
return n == 1, nil
}
func (db *DB) ForceUnlock(state *model.State) error {
_, err := db.Exec(
`UPDATE states
SET lock = NULL
WHERE id = ?;`,
state.Id)
if err != nil {
return fmt.Errorf("failed to update state: %w", err)
}
return nil
}