commit 60639a6a0ee9ee79a93d998697b083314e840e9c
parent d9bbcc60a6cd32282de907a2090c674c4616219e
Author: tobi <31960611+tsmethurst@users.noreply.github.com>
Date: Fri, 31 Mar 2023 15:19:50 +0200
[bugfix] Fix multiple "updated_at" columns for media updates (#1660)
* [bugfix] Fix multiple "updated_at" columns for media updates
* silly unrelated race condition
Diffstat:
3 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/internal/media/prune.go b/internal/media/prune.go
@@ -328,10 +328,8 @@ func (m *manager) uncacheAttachment(ctx context.Context, attachment *gtsmodel.Me
}
// Update attachment to reflect that we no longer have it cached.
- attachment.UpdatedAt = time.Now()
- cached := false
- attachment.Cached = &cached
- return m.state.DB.UpdateAttachment(ctx, attachment, "updated_at", "cached")
+ attachment.Cached = func() *bool { i := false; return &i }()
+ return m.state.DB.UpdateAttachment(ctx, attachment, "cached")
}
func (m *manager) removeFiles(ctx context.Context, keys ...string) (int, error) {
diff --git a/internal/processing/account_test.go b/internal/processing/account_test.go
@@ -88,7 +88,7 @@ func (suite *AccountTestSuite) TestAccountDeleteLocal() {
if !testrig.WaitFor(func() bool {
dbAccount, _ := suite.db.GetAccountByID(ctx, deletingAccount.ID)
- return suite.WithinDuration(dbAccount.SuspendedAt, time.Now(), 30*time.Second)
+ return !dbAccount.SuspendedAt.IsZero()
}) {
suite.FailNow("timed out waiting for account to be deleted")
}
diff --git a/internal/processing/media/unattach.go b/internal/processing/media/unattach.go
@@ -21,7 +21,6 @@ import (
"context"
"errors"
"fmt"
- "time"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/db"
@@ -44,11 +43,9 @@ func (p *Processor) Unattach(ctx context.Context, account *gtsmodel.Account, med
return nil, gtserror.NewErrorNotFound(errors.New("attachment not owned by requesting account"))
}
- updatingColumns := []string{"updated_at", "status_id"}
- attachment.UpdatedAt = time.Now()
attachment.StatusID = ""
- if err := p.state.DB.UpdateAttachment(ctx, attachment, updatingColumns...); err != nil {
+ if err := p.state.DB.UpdateAttachment(ctx, attachment, "status_id"); err != nil {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("db error updating attachment: %s", err))
}