mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
fix(coderd/workspaceapps): prevent race in workspace app audit session updates (#17020)
Fixes coder/internal#520
This commit is contained in:
committed by
GitHub
parent
68624092a4
commit
72d9876c76
@ -12298,10 +12298,10 @@ func (q *FakeQuerier) UpsertWorkspaceAgentPortShare(_ context.Context, arg datab
|
||||
return psl, nil
|
||||
}
|
||||
|
||||
func (q *FakeQuerier) UpsertWorkspaceAppAuditSession(_ context.Context, arg database.UpsertWorkspaceAppAuditSessionParams) (time.Time, error) {
|
||||
func (q *FakeQuerier) UpsertWorkspaceAppAuditSession(_ context.Context, arg database.UpsertWorkspaceAppAuditSessionParams) (bool, error) {
|
||||
err := validateDatabaseType(arg)
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
return false, err
|
||||
}
|
||||
|
||||
q.mutex.Lock()
|
||||
@ -12335,10 +12335,11 @@ func (q *FakeQuerier) UpsertWorkspaceAppAuditSession(_ context.Context, arg data
|
||||
|
||||
q.workspaceAppAuditSessions[i].UpdatedAt = arg.UpdatedAt
|
||||
if !fresh {
|
||||
q.workspaceAppAuditSessions[i].ID = arg.ID
|
||||
q.workspaceAppAuditSessions[i].StartedAt = arg.StartedAt
|
||||
return arg.StartedAt, nil
|
||||
return true, nil
|
||||
}
|
||||
return s.StartedAt, nil
|
||||
return false, nil
|
||||
}
|
||||
|
||||
q.workspaceAppAuditSessions = append(q.workspaceAppAuditSessions, database.WorkspaceAppAuditSession{
|
||||
@ -12352,7 +12353,7 @@ func (q *FakeQuerier) UpsertWorkspaceAppAuditSession(_ context.Context, arg data
|
||||
StartedAt: arg.StartedAt,
|
||||
UpdatedAt: arg.UpdatedAt,
|
||||
})
|
||||
return arg.StartedAt, nil
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (q *FakeQuerier) GetAuthorizedTemplates(ctx context.Context, arg database.GetTemplatesWithFilterParams, prepared rbac.PreparedAuthorized) ([]database.Template, error) {
|
||||
|
Reference in New Issue
Block a user