mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-22 10:12:11 +00:00
[bugfix] Fix multiple "updated_at" columns for media updates (#1660)
* [bugfix] Fix multiple "updated_at" columns for media updates * silly unrelated race condition
This commit is contained in:
parent
d9bbcc60a6
commit
60639a6a0e
|
@ -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) {
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
"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))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue