mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Update edge case bug in ds.UpdateHostDeviceMapping (#15454)
Found by @mna while working on #14779. Sort of an edge case but the change is simple enough to fix it.
This commit is contained in:
parent
57351011fa
commit
33ceb0ab9f
1 changed files with 7 additions and 7 deletions
|
|
@ -2862,14 +2862,14 @@ func (ds *Datastore) ReplaceHostDeviceMapping(ctx context.Context, hid uint, map
|
|||
insPart = ` (?, ?, ?),`
|
||||
)
|
||||
|
||||
// index the mappings by email and source, to quickly check which ones
|
||||
// need to be deleted and inserted
|
||||
toIns := make(map[string]*fleet.HostDeviceMapping)
|
||||
for _, m := range mappings {
|
||||
toIns[m.Email+"\n"+m.Source] = m
|
||||
}
|
||||
|
||||
return ds.withRetryTxx(ctx, func(tx sqlx.ExtContext) error {
|
||||
// index the mappings by email and source, to quickly check which ones
|
||||
// need to be deleted and inserted
|
||||
toIns := make(map[string]*fleet.HostDeviceMapping)
|
||||
for _, m := range mappings {
|
||||
toIns[m.Email+"\n"+m.Source] = m
|
||||
}
|
||||
|
||||
var prevMappings []*fleet.HostDeviceMapping
|
||||
if err := sqlx.SelectContext(ctx, tx, &prevMappings, selStmt, hid); err != nil {
|
||||
return ctxerr.Wrap(ctx, err, "select previous host emails")
|
||||
|
|
|
|||
Loading…
Reference in a new issue