summaryrefslogtreecommitdiffstats
path: root/lib/puppet/indirector
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/indirector')
-rw-r--r--lib/puppet/indirector/envelope.rb4
-rw-r--r--lib/puppet/indirector/indirection.rb29
-rw-r--r--lib/puppet/indirector/ssl_file.rb2
3 files changed, 15 insertions, 20 deletions
diff --git a/lib/puppet/indirector/envelope.rb b/lib/puppet/indirector/envelope.rb
index ef7952ef6..5fdea7081 100644
--- a/lib/puppet/indirector/envelope.rb
+++ b/lib/puppet/indirector/envelope.rb
@@ -6,8 +6,6 @@ module Puppet::Indirector::Envelope
attr_accessor :expiration
def expired?
- return false unless expiration
- return false if expiration >= Time.now
- return true
+ expiration and expiration < Time.now
end
end
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index dc7e58f36..d762701f5 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -161,22 +161,19 @@ class Puppet::Indirector::Indirection
end
end
- # Expire a cached object, if one is cached. Note that we don't actually
- # remove it, we expire it and write it back out to disk. This way people
- # can still use the expired object if they want.
+ # Expire a cached object, if one is cached. Note that we now actually
+ # remove it if possible, and only mark it as expired if destroy isn't
+ # supported.
def expire(key, *args)
- request = request(:expire, key, *args)
-
- return nil unless cache?
-
- return nil unless instance = cache.find(request(:find, key, *args))
-
- Puppet.info "Expiring the %s cache of %s" % [self.name, instance.name]
-
- # Set an expiration date in the past
- instance.expiration = Time.now - 60
-
- cache.save(request(:save, instance, *args))
+ if cache? and instance = cache.find(request(:find, key, *args))
+ Puppet.info "Expiring the #{name} cache of #{instance.name}"
+ if cache.respond_to? :destroy
+ cache.destroy(request(:destroy, instance, *args))
+ else
+ instance.expiration = Time.now - 1
+ cache.save(request(:save,instance,*args))
+ end
+ end
end
# Search for an instance in the appropriate terminus, caching the
@@ -216,7 +213,7 @@ class Puppet::Indirector::Indirection
return nil
end
- Puppet.debug "Using cached %s for %s" % [self.name, request.key]
+ Puppet.debug "Using cached #{name} for #{request.key}, good until #{cached.expiration}"
return cached
end
diff --git a/lib/puppet/indirector/ssl_file.rb b/lib/puppet/indirector/ssl_file.rb
index 67202699d..fc1e65d22 100644
--- a/lib/puppet/indirector/ssl_file.rb
+++ b/lib/puppet/indirector/ssl_file.rb
@@ -91,7 +91,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
def save(request)
path = path(request.key)
dir = File.dirname(path)
-
+
raise Puppet::Error.new("Cannot save %s; parent directory %s does not exist" % [request.key, dir]) unless FileTest.directory?(dir)
raise Puppet::Error.new("Cannot save %s; parent directory %s is not writable" % [request.key, dir]) unless FileTest.writable?(dir)