diff options
author | David Schmitt <david@dasz.at> | 2010-05-18 16:33:47 +0200 |
---|---|---|
committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
commit | a6b52bb01b0c73d36d6b40c263e7542cb5cfbfff (patch) | |
tree | beb1ba6622aac8d28ddff619cc939b7444e3d1e0 /lib/puppet | |
parent | 533ef68e47a124182066432c11040bbb6120b658 (diff) | |
download | puppet-a6b52bb01b0c73d36d6b40c263e7542cb5cfbfff.tar.gz puppet-a6b52bb01b0c73d36d6b40c263e7542cb5cfbfff.tar.xz puppet-a6b52bb01b0c73d36d6b40c263e7542cb5cfbfff.zip |
Avoid trying to lock on non-files
This is not supported on windows and makes little sense on POSIX
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/util/file_locking.rb | 2 |
1 files changed, 2 insertions, 0 deletions
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 |