fix install lock db

Signed-off-by: Ronni Skansing <rskansing@gmail.com>
This commit is contained in:
Ronni Skansing
2025-08-23 11:49:22 +02:00
parent e00aa6c3cd
commit 6fa07a8c3c
3 changed files with 10 additions and 4 deletions

2
RELEASE.md Normal file
View File

@@ -0,0 +1,2 @@
# 1.1.9
- Fixed bug in install.

View File

@@ -143,16 +143,19 @@ type Install struct {
// Install completes the installation by setting the initial administrators and options
func (in *Install) Install(g *gin.Context) {
tx := in.DB.Begin()
var committed bool
defer func() {
if r := recover(); r != nil {
tx.Rollback()
if !committed {
tx.Rollback()
}
}
}()
ok := in.install(g, tx)
if !ok {
if tx.Rollback().Error != nil {
if err := tx.Rollback().Error; err != nil {
in.Logger.Errorw("failed to install - could not rollback transaction",
"error", tx.Rollback().Error,
"error", err,
)
}
return
@@ -165,6 +168,7 @@ func (in *Install) Install(g *gin.Context) {
in.Response.ServerError(g)
return
}
committed = true
// the admin user changed username and password
// however as the install process is a special case, we wont
// require re-authentication

View File

@@ -37,7 +37,7 @@ func (o *Option) updateByKey(
d *gorm.DB,
option *model.Option,
) error {
result := o.DB.
result := d.
Model(&database.Option{}).
Where("key = ?", option.Key.String()).
Update("value", option.Value.String())