guard profile update after being set

This commit is contained in:
Carlosokumu 2024-12-27 10:07:05 +03:00
parent 235af3519d
commit 5579991d66
Signed by: carlos
GPG Key ID: 7BD6BC8160A5C953

View File

@ -1986,17 +1986,18 @@ func (h *Handlers) insertProfileItems(ctx context.Context, sessionId string, res
for index, profileItem := range h.profile.ProfileItems {
// Ensure the profileItem is not "0"(is set)
if profileItem != "0" {
flag, _ := h.flagManager.GetFlag(profileFlagNames[index])
isProfileItemSet := h.st.MatchFlag(flag, true)
if !isProfileItemSet {
err = store.WriteEntry(ctx, sessionId, profileDataKeys[index], []byte(profileItem))
if err != nil {
logg.ErrorCtxf(ctx, "failed to write profile entry with", "key", profileDataKeys[index], "value", profileItem, "error", err)
return err
}
// Get the flag for the current index
flag, _ := h.flagManager.GetFlag(profileFlagNames[index])
res.FlagSet = append(res.FlagSet, flag)
}
}
}
return nil
}