Signed-off-by: Paul Nasrat <[EMAIL PROTECTED]>
---
 lib/puppet/network/handler/fileserver.rb |   25 ++++++++++++++-----------
 spec/unit/type/file.rb                   |   17 ++++++++++-------
 2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/lib/puppet/network/handler/fileserver.rb 
b/lib/puppet/network/handler/fileserver.rb
index 3e62cdb..6bd6f2f 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -656,30 +656,25 @@ class Puppet::Network::Handler
 
             # Recursively list the files in this tree.
             def reclist(basepath, abspath, recurse, ignore)
+                return if abspath.nil? and not FileTest.exists?(basepath)
                 abspath = basepath if abspath.nil?
-                relpath = abspath.sub(%r{^#{basepath}}, '')
-                relpath = "/#{relpath}" if relpath[0] != ?/  #/
-                
-                return unless FileTest.exists?(abspath)
-                
-                desc = [relpath]
                 
-                ftype = File.stat(abspath).ftype
-
-                desc << ftype
                 if recurse.is_a?(Integer)
                     recurse -= 1
                 end
 
+                desc = pathdesc(abspath, basepath)
                 ary = [desc]
+
                 if recurse == true or (recurse.is_a?(Integer) and recurse > -1)
-                    if ftype == "directory"
+                    if FileTest.directory?(abspath)
                         children = Dir.entries(abspath)
                         if ignore
                             children = handleignore(children, abspath, ignore)
-                        end  
+                        end
                         children.each { |child|
                             next if child =~ /^\.\.?$/
+                            next unless FileTest.exists?(File.join(abspath, 
child))
                             reclist(basepath, File.join(abspath, child), 
recurse, ignore).each { |cobj|
                                 ary << cobj
                             }
@@ -690,6 +685,14 @@ class Puppet::Network::Handler
                 return ary.compact
             end
 
+            def pathdesc(abspath, basepath)
+                relpath = abspath.sub(%r{^#{basepath}}, '')
+                relpath = "/#{relpath}" if relpath[0] != ?/  #/
+                desc = [relpath]
+                ftype = File.stat(abspath).ftype
+                desc << ftype
+            end
+
             # Deal with ignore parameters.
             def handleignore(files, path, ignore_patterns)
                 ignore_patterns.each do |ignore|
diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb
index 3e94bc1..2c55545 100755
--- a/spec/unit/type/file.rb
+++ b/spec/unit/type/file.rb
@@ -112,34 +112,37 @@ describe Puppet::Type.type(:file) do
             ("%o" % (File.stat(@file).mode & 007777)).should == "%o" % 0755
         end
 
-        it "should recursively copy directories" do
-            @copy_resource = Puppet.type(:file).create(
+        it "should recursively copy links as files" do
+            copy_resource = Puppet.type(:file).create(
                 :path => @todir,
                 :source => @basedir,
                 :ensure => "directory",
                 :recurse => true
             )
 
-            @catalog.add_resource @copy_resource
+            @catalog.add_resource copy_resource
             @catalog.apply
 
             Dir.entries(@todir).should include("file")
             Dir.entries(@todir).should include("link")
         end
 
-        it "should default to copy dangling symlinks as links" do
+        it "should ignore dangling symlinks" do
 
             dangling_link = File.join(@basedir, "dangling_link")
             File.symlink("/some/where/else", dangling_link)
-            @symlink_resource = Puppet.type(:file).create(
+            symlink_resource = Puppet.type(:file).create(
                 :path => @todir,
                 :source => @basedir,
                 :ensure => "directory",
                 :recurse => true
             )
 
-            @catalog.add_resource @symlink_resource
-            lambda { @symlink_resource.eval_generate }.should_not raise_error
+            @catalog.add_resource symlink_resource
+            lambda { symlink_resource.eval_generate }.should_not raise_error
+            @catalog.apply
+            Dir.entries(@todir).should include("file")
+            Dir.entries(@todir).should include("link")
         end
     end
 
-- 
1.5.3.4


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to