From d15dab703ccc5cd85a414bebba1fafd3c17e2d37 Mon Sep 17 00:00:00 2001 From: Jesse Peterson Date: Wed, 10 Feb 2021 11:21:22 -0800 Subject: [PATCH] Avoid queue save when not needed (#711) * Avoid queue save when not needed --- platform/queue/queue.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/queue/queue.go b/platform/queue/queue.go index 298bdc13..f9d4e783 100644 --- a/platform/queue/queue.go +++ b/platform/queue/queue.go @@ -164,8 +164,12 @@ func (db *Store) nextCommand(ctx context.Context, resp mdm.Response) (*Command, } } - if err := db.Save(dc); err != nil { - return nil, err + // we only need to Save if there are command queue changes such as + // NowNow and Acknowledged responses or a new popped command. + if resp.Status != "Idle" || cmd != nil { + if err := db.Save(dc); err != nil { + return nil, err + } } return cmd, nil