engine: resources: Improving logging even more

Messages should happen after the event on success. The error scenario
has its own pathway to report.
This commit is contained in:
James Shubin
2025-03-27 01:09:17 -04:00
parent f71e623931
commit 7f341cee84

View File

@@ -721,10 +721,10 @@ func (obj *FileRes) dirCheckApply(ctx context.Context, apply bool) (bool, error)
// the path exists and is not a directory // the path exists and is not a directory
// delete the file if force is given // delete the file if force is given
if err == nil && !fileInfo.IsDir() { if err == nil && !fileInfo.IsDir() {
obj.init.Logf("removing (force): %s", obj.getPath())
if err := os.Remove(obj.getPath()); err != nil { if err := os.Remove(obj.getPath()); err != nil {
return false, err return false, err
} }
obj.init.Logf("force remove")
} }
// create the empty directory // create the empty directory
@@ -737,11 +737,19 @@ func (obj *FileRes) dirCheckApply(ctx context.Context, apply bool) (bool, error)
if obj.Recurse { if obj.Recurse {
// TODO: add recurse limit here // TODO: add recurse limit here
if err := os.MkdirAll(obj.getPath(), mode); err != nil {
return false, err
}
obj.init.Logf("mkdir -p -m %s", mode) obj.init.Logf("mkdir -p -m %s", mode)
return false, os.MkdirAll(obj.getPath(), mode) return false, nil
} }
return false, os.Mkdir(obj.getPath(), mode) if err := os.Mkdir(obj.getPath(), mode); err != nil {
return false, err
}
obj.init.Logf("mkdir -m %s", mode)
return false, nil
} }
// syncCheckApply is the CheckApply operation for a source and destination dir. // syncCheckApply is the CheckApply operation for a source and destination dir.