mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-28 03:11:01 +00:00
fix error with instance not created on startup (#156)
This commit is contained in:
parent
d39d93e852
commit
14ebc94fd9
1 changed files with 13 additions and 11 deletions
|
@ -235,17 +235,17 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) db.Error {
|
||||||
domain := a.config.Host
|
domain := a.config.Host
|
||||||
|
|
||||||
// check if instance entry already exists
|
// check if instance entry already exists
|
||||||
existsQ := a.conn.
|
q := a.conn.
|
||||||
NewSelect().
|
NewSelect().
|
||||||
Model(>smodel.Instance{}).
|
Model(>smodel.Instance{}).
|
||||||
Where("domain = ?", domain)
|
Where("domain = ?", domain)
|
||||||
|
|
||||||
count, err := existsQ.Count(ctx)
|
exists, err := exists(ctx, q)
|
||||||
if err != nil && count == 1 {
|
if err != nil {
|
||||||
a.log.Infof("instance instance %s already exists", domain)
|
return err
|
||||||
return nil
|
}
|
||||||
} else if err != sql.ErrNoRows {
|
if exists {
|
||||||
return processErrorResponse(err)
|
a.log.Infof("instance entry already exists")
|
||||||
}
|
}
|
||||||
|
|
||||||
iID, err := id.NewRandomULID()
|
iID, err := id.NewRandomULID()
|
||||||
|
@ -264,9 +264,11 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) db.Error {
|
||||||
NewInsert().
|
NewInsert().
|
||||||
Model(i)
|
Model(i)
|
||||||
|
|
||||||
if _, err := insertQ.Exec(ctx); err != nil {
|
_, err = insertQ.Exec(ctx)
|
||||||
return err
|
err = processErrorResponse(err)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
a.log.Infof("created instance instance %s with id %s", domain, i.ID)
|
||||||
}
|
}
|
||||||
a.log.Infof("created instance instance %s with id %s", domain, i.ID)
|
return err
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue