summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-29 17:30:47 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-01-29 17:30:47 +0000
commit04017b3399f8e0b2421b38864fa6593dfc3eec78 (patch)
tree56ec30e22681a31f7e8fc30250594d3cf58e4ec7
parentb7560d54ebf1b8908e4961c6667cb9c8ec1e00dc (diff)
downloadpuppet-04017b3399f8e0b2421b38864fa6593dfc3eec78.tar.gz
puppet-04017b3399f8e0b2421b38864fa6593dfc3eec78.tar.xz
puppet-04017b3399f8e0b2421b38864fa6593dfc3eec78.zip
Fixing #444. I was losing the list of sources when creating new children.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2111 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/type/pfile.rb11
-rwxr-xr-xtest/types/filesources.rb24
2 files changed, 34 insertions, 1 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index 03453d3fc..bab737f4f 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -845,6 +845,7 @@ module Puppet
result = []
found = []
+
@states[:source].should.each do |source|
sourceobj, path = uri2obj(source)
@@ -869,7 +870,15 @@ module Puppet
# for conflicting files.
next if found.include?(name)
- args = {:source => source + file}
+ # For directories, keep all of the sources, so that sourceselect still works as planned.
+ if type == "directory"
+ newsource = @states[:source].should.collect do |source|
+ source + file
+ end
+ else
+ newsource = source + file
+ end
+ args = {:source => newsource}
if type == file
args[:recurse] = nil
end
diff --git a/test/types/filesources.rb b/test/types/filesources.rb
index 1a4c61793..915f19833 100755
--- a/test/types/filesources.rb
+++ b/test/types/filesources.rb
@@ -984,6 +984,30 @@ class TestFileSources < Test::Unit::TestCase
assert(FileTest.exists?(file3), "File from source 1 was not copied")
assert_equal("0", File.read(file3), "file3 got wrong contents")
end
+
+ def test_recursive_sourceselect
+ dest = tempfile()
+ source1 = tempfile()
+ source2 = tempfile()
+ files = []
+ [source1, source2, File.join(source1, "subdir"), File.join(source2, "subdir")].each_with_index do |dir, i|
+ Dir.mkdir(dir)
+ file = File.join(dir, "file%s" % i)
+ File.open(file, "w") { |f| f.puts "yay%s" % i}
+ files << file
+ end
+
+ obj = Puppet::Type.newfile(:path => dest, :source => [source1, source2], :sourceselect => :all, :recurse => true)
+
+ assert_apply(obj)
+
+ ["file0", "file1", "subdir/file2", "subdir/file3"].each do |file|
+ path = File.join(dest, file)
+ assert(FileTest.exists?(path), "did not create %s" % file)
+
+ assert_equal("yay%s\n" % File.basename(file).sub("file", ''), File.read(path), "file was not copied correctly")
+ end
+ end
end
# $Id$