From a6b52bb01b0c73d36d6b40c263e7542cb5cfbfff Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 18 May 2010 16:33:47 +0200 Subject: Avoid trying to lock on non-files This is not supported on windows and makes little sense on POSIX --- lib/puppet/util/file_locking.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/puppet/util/file_locking.rb b/lib/puppet/util/file_locking.rb index 101ece308..f1f02be1c 100644 --- a/lib/puppet/util/file_locking.rb +++ b/lib/puppet/util/file_locking.rb @@ -5,6 +5,7 @@ module Puppet::Util::FileLocking # Create a shared lock for reading def readlock(file) + raise ArgumentError, "%s is not a file" % file unless !File.exists?(file) or File.file?(file) Puppet::Util.sync(file).synchronize(Sync::SH) do File.open(file) { |f| f.lock_shared { |lf| yield lf } @@ -18,6 +19,7 @@ module Puppet::Util::FileLocking unless FileTest.directory?(File.dirname(file)) raise Puppet::DevError, "Cannot create %s; directory %s does not exist" % [file, File.dirname(file)] end + raise ArgumentError, "%s is not a file" % file unless !File.exists?(file) or File.file?(file) tmpfile = file + ".tmp" unless mode -- cgit