mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-22 11:46:40 +00:00
[bugfix] on deref new account, check db again for account on ErrAlreadyExists (#1581)
Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
bfccf4e450
commit
fe6c8b8152
|
@ -293,8 +293,15 @@ func (d *deref) enrichAccount(ctx context.Context, requestUser string, uri *url.
|
||||||
latestAcc.CreatedAt = latestAcc.FetchedAt
|
latestAcc.CreatedAt = latestAcc.FetchedAt
|
||||||
latestAcc.UpdatedAt = latestAcc.FetchedAt
|
latestAcc.UpdatedAt = latestAcc.FetchedAt
|
||||||
|
|
||||||
// This is a new account, we need to place it in the database.
|
// This is new, put it in the database.
|
||||||
if err := d.db.PutAccount(ctx, latestAcc); err != nil {
|
err := d.db.PutAccount(ctx, latestAcc)
|
||||||
|
|
||||||
|
if errors.Is(err, db.ErrAlreadyExists) {
|
||||||
|
// TODO: replace this quick fix with per-URI deref locks.
|
||||||
|
latestAcc, err = d.db.GetAccountByURI(ctx, latestAcc.URI)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
return nil, fmt.Errorf("enrichAccount: error putting in database: %w", err)
|
return nil, fmt.Errorf("enrichAccount: error putting in database: %w", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue