Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domcleal/1948910 to your computer and use it in GitHub Desktop.
Save domcleal/1948910 to your computer and use it in GitHub Desktop.
From 900a053a994a26129f3412e35ba39657cfab8c2c Mon Sep 17 00:00:00 2001
From: Dominic Cleal <dcleal@redhat.com>
Date: Thu, 1 Mar 2012 08:31:44 +0000
Subject: [PATCH] (#11988) Work around Augeas reload bug when changing save
modes
After saving a file in one save mode and switching to another, Augeas realise
to reload the file when Augeas#load is called again. Work around this by
explicitly reloading all files we saved while using the first save mode.
---
lib/puppet/provider/augeas/augeas.rb | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index 303c59d..5352f49 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -321,9 +321,15 @@ Puppet::Type.type(:augeas).provide(:augeas) do
end
def execute_changes
+ # Workaround Augeas bug where changing the save mode doesn't trigger a
+ # reload of the previously saved file(s) when we call Augeas#load
+ @aug.match("/augeas/events/saved").each do |file|
+ @aug.rm("/augeas#{@aug.get(file)}/mtime")
+ end
+
# Reload augeas, and execute the changes for real
- aug.load
set_augeas_save_mode(SAVE_OVERWRITE) if versioncmp(get_augeas_version, "0.3.6") >= 0
+ @aug.load
do_execute_changes
success = @aug.save
fail("Save failed with return code #{success}") if success != true
--
1.7.7.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment