Skip to content

Commit dd79a5a

Browse files
committed
Properly handle promise locking with edit line
Fixed bug causing rendered files can result in erroneously empty files as a result of promise locking. Ticket: ENT-9980 Changelog: Commit Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent a5dd749 commit dd79a5a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cf-agent/verify_files.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,10 @@ static PromiseResult RenderTemplateCFEngine(EvalContext *ctx,
754754
EvalContextStackPushBundleFrame(ctx, bp, bundle_args, a.edits.inherit);
755755
BundleResolve(ctx, bp);
756756

757-
ScheduleEditLineOperations(ctx, bp, &a, pp, edcontext);
757+
/* We don't record the change yet, because it may be changed to
758+
* PROMISE_RESULT_NOOP if there is no diff in contents */
759+
result = ScheduleEditLineOperations(ctx, bp, &a, pp, edcontext)
760+
? PROMISE_RESULT_CHANGE : PROMISE_RESULT_SKIPPED;
758761

759762
EvalContextStackPopFrame(ctx);
760763

@@ -1014,7 +1017,10 @@ PromiseResult ScheduleEditOperation(EvalContext *ctx, char *filename,
10141017

10151018
BundleResolve(ctx, bp);
10161019

1017-
ScheduleEditLineOperations(ctx, bp, a, pp, edcontext);
1020+
/* We don't record the change yet, because it may be changed to
1021+
* PROMISE_RESULT_NOOP if there is no diff in contents */
1022+
result = ScheduleEditLineOperations(ctx, bp, a, pp, edcontext)
1023+
? PROMISE_RESULT_CHANGE : PROMISE_RESULT_SKIPPED;
10181024

10191025
EvalContextStackPopFrame(ctx);
10201026
}

0 commit comments

Comments
 (0)