From d39d93e85261adc75bd8ce553c1b0aab1341e71a Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 26 Aug 2021 12:36:08 +0200 Subject: [PATCH 1/3] update drone yml (#153) --- .drone.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 ... From 14ebc94fd97dcbe19f524e6da3cd1f0340e87ec9 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 26 Aug 2021 17:22:41 +0200 Subject: [PATCH 2/3] fix error with instance not created on startup (#156) --- internal/db/bundb/admin.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/internal/db/bundb/admin.go b/internal/db/bundb/admin.go index 09f2d3bff..53b6ae0c2 100644 --- a/internal/db/bundb/admin.go +++ b/internal/db/bundb/admin.go @@ -235,17 +235,17 @@ 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) - return nil - } else if err != sql.ErrNoRows { - return processErrorResponse(err) + exists, err := exists(ctx, q) + if err != nil { + return err + } + if exists { + a.log.Infof("instance entry already exists") } iID, err := id.NewRandomULID() @@ -264,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 = 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 nil + return err } From 2eefaa0227798635baac647b1ac3bc68cdd0e98f Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 26 Aug 2021 17:46:24 +0200 Subject: [PATCH 3/3] oops (#157) --- internal/db/bundb/admin.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/db/bundb/admin.go b/internal/db/bundb/admin.go index 53b6ae0c2..d43501444 100644 --- a/internal/db/bundb/admin.go +++ b/internal/db/bundb/admin.go @@ -246,6 +246,7 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) db.Error { } if exists { a.log.Infof("instance entry already exists") + return nil } iID, err := id.NewRandomULID()