mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-30 00:36:14 -06:00
Merge remote-tracking branch 'upstream/main' into feature/add-sqlite-support
Signed-off-by: kim (grufwub) <grufwub@gmail.com>
This commit is contained in:
commit
63412d565b
2 changed files with 19 additions and 11 deletions
|
|
@ -234,17 +234,18 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) db.Error {
|
|||
domain := a.config.Host
|
||||
|
||||
// check if instance entry already exists
|
||||
existsQ := a.conn.
|
||||
q := a.conn.
|
||||
NewSelect().
|
||||
Model(>smodel.Instance{}).
|
||||
Where("domain = ?", domain)
|
||||
|
||||
count, err := existsQ.Count(ctx)
|
||||
if err != nil && count == 1 {
|
||||
a.log.Infof("instance instance %s already exists", domain)
|
||||
exists, err := a.conn.Exists(ctx, q)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if exists {
|
||||
a.log.Infof("instance entry already exists")
|
||||
return nil
|
||||
} else if err != sql.ErrNoRows {
|
||||
return a.conn.ProcessError(err)
|
||||
}
|
||||
|
||||
iID, err := id.NewRandomULID()
|
||||
|
|
@ -263,9 +264,11 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) db.Error {
|
|||
NewInsert().
|
||||
Model(i)
|
||||
|
||||
if _, err := insertQ.Exec(ctx); err != nil {
|
||||
return err
|
||||
_, err = insertQ.Exec(ctx)
|
||||
err = a.conn.ProcessError(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 nil
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue