diff --git a/.drone.yml b/.drone.yml index f6c257216..ad163780e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -79,8 +79,13 @@ volumes: host: path: /drone/gotosocial/golangci-lint +trigger: + repo: + - superseriousbusiness/gotosocial + - NyaaaWhatsUpDoc/gotosocial + --- kind: signature -hmac: 9134975e238ab9f92a7f75ccc11279e8d5edddb87f10165ed3c7d23fdd9c8a11 +hmac: 7fa6fa70be0a5c436ecb2f02f4b74bd1be5e90817e2d95a16898e3d29cbadf80 ... diff --git a/internal/db/bundb/admin.go b/internal/db/bundb/admin.go index 29c353a56..1f70c0e64 100644 --- a/internal/db/bundb/admin.go +++ b/internal/db/bundb/admin.go @@ -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 }