59
59
#include <known_dirs.h>
60
60
#include <evalfunction.h>
61
61
#include <changes_chroot.h> /* PrepareChangesChroot(), RecordFileChangedInChroot() */
62
+ #include <cf3.defs.h>
62
63
63
64
static PromiseResult FindFilePromiserObjects (EvalContext * ctx , const Promise * pp );
64
65
static PromiseResult VerifyFilePromise (EvalContext * ctx , char * path , const Promise * pp );
@@ -728,7 +729,8 @@ static PromiseResult RenderTemplateCFEngine(EvalContext *ctx,
728
729
const Rlist * bundle_args ,
729
730
const Attributes * attr ,
730
731
EditContext * edcontext ,
731
- bool file_exists )
732
+ bool file_exists ,
733
+ bool * save_file )
732
734
{
733
735
assert (edcontext != NULL );
734
736
assert (attr != NULL );
@@ -741,7 +743,7 @@ static PromiseResult RenderTemplateCFEngine(EvalContext *ctx,
741
743
{
742
744
if (!file_exists && !CfCreateFile (ctx , edcontext -> changes_filename ,
743
745
pp , attr , & result ))
744
- {
746
+ {
745
747
RecordFailure (ctx , pp , attr ,
746
748
"Failed to create file '%s' for rendering cfengine template '%s'" ,
747
749
edcontext -> filename , attr -> edit_template );
@@ -753,7 +755,7 @@ static PromiseResult RenderTemplateCFEngine(EvalContext *ctx,
753
755
EvalContextStackPushBundleFrame (ctx , bp , bundle_args , a .edits .inherit );
754
756
BundleResolve (ctx , bp );
755
757
756
- ScheduleEditLineOperations (ctx , bp , & a , pp , edcontext );
758
+ * save_file = ScheduleEditLineOperations (ctx , bp , & a , pp , edcontext );
757
759
758
760
EvalContextStackPopFrame (ctx );
759
761
@@ -853,7 +855,7 @@ static PromiseResult RenderTemplateMustache(EvalContext *ctx,
853
855
if (!file_exists && !CfCreateFile (ctx ,
854
856
edcontext -> changes_filename ,
855
857
pp , attr , & result ))
856
- {
858
+ {
857
859
RecordFailure (ctx , pp , attr ,
858
860
"Failed to create file '%s' for rendering mustache template '%s'" ,
859
861
edcontext -> filename , message );
@@ -964,6 +966,7 @@ PromiseResult ScheduleEditOperation(EvalContext *ctx, char *filename,
964
966
Rlist * args = NULL ;
965
967
char edit_bundle_name [CF_BUFSIZE ], lockname [CF_BUFSIZE ];
966
968
CfLock thislock ;
969
+ bool save_file = true;
967
970
968
971
snprintf (lockname , CF_BUFSIZE - 1 , "fileedit-%s" , filename );
969
972
thislock = AcquireLock (ctx , lockname , VUQNAME , CFSTARTTIME , a -> transaction .ifelapsed , a -> transaction .expireafter , pp , false);
@@ -1066,7 +1069,8 @@ PromiseResult ScheduleEditOperation(EvalContext *ctx, char *filename,
1066
1069
PromiseResult render_result = RenderTemplateCFEngine (ctx , pp ,
1067
1070
args , a ,
1068
1071
edcontext ,
1069
- file_exists );
1072
+ file_exists ,
1073
+ & save_file );
1070
1074
result = PromiseResultUpdate (result , render_result );
1071
1075
}
1072
1076
}
@@ -1098,7 +1102,7 @@ PromiseResult ScheduleEditOperation(EvalContext *ctx, char *filename,
1098
1102
}
1099
1103
1100
1104
exit :
1101
- FinishEditContext (ctx , edcontext , a , pp , & result );
1105
+ FinishEditContext (ctx , edcontext , a , pp , & result , save_file );
1102
1106
YieldCurrentLock (thislock );
1103
1107
if (result == PROMISE_RESULT_CHANGE )
1104
1108
{
0 commit comments