mirror of
				https://github.com/superseriousbusiness/gotosocial
				synced 2025-06-05 21:59:39 +02: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:
		| @@ -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. | 	// Update attachment to reflect that we no longer have it cached. | ||||||
| 	attachment.UpdatedAt = time.Now() | 	attachment.Cached = func() *bool { i := false; return &i }() | ||||||
| 	cached := false | 	return m.state.DB.UpdateAttachment(ctx, attachment, "cached") | ||||||
| 	attachment.Cached = &cached |  | ||||||
| 	return m.state.DB.UpdateAttachment(ctx, attachment, "updated_at", "cached") |  | ||||||
| } | } | ||||||
|  |  | ||||||
| func (m *manager) removeFiles(ctx context.Context, keys ...string) (int, error) { | func (m *manager) removeFiles(ctx context.Context, keys ...string) (int, error) { | ||||||
|   | |||||||
| @@ -88,7 +88,7 @@ func (suite *AccountTestSuite) TestAccountDeleteLocal() { | |||||||
|  |  | ||||||
| 	if !testrig.WaitFor(func() bool { | 	if !testrig.WaitFor(func() bool { | ||||||
| 		dbAccount, _ := suite.db.GetAccountByID(ctx, deletingAccount.ID) | 		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") | 		suite.FailNow("timed out waiting for account to be deleted") | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -21,7 +21,6 @@ import ( | |||||||
| 	"context" | 	"context" | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"time" |  | ||||||
|  |  | ||||||
| 	apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" | 	apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" | ||||||
| 	"github.com/superseriousbusiness/gotosocial/internal/db" | 	"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")) | 		return nil, gtserror.NewErrorNotFound(errors.New("attachment not owned by requesting account")) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	updatingColumns := []string{"updated_at", "status_id"} |  | ||||||
| 	attachment.UpdatedAt = time.Now() |  | ||||||
| 	attachment.StatusID = "" | 	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)) | 		return nil, gtserror.NewErrorNotFound(fmt.Errorf("db error updating attachment: %s", err)) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user