removed described? logic from insync? in ensure.rb and source.rb

raise in source#retrieve if the source is not found

Signed-off-by: Andrew Shafer <[EMAIL PROTECTED]>
---
 lib/puppet/type/file/ensure.rb |    5 -----
 lib/puppet/type/file/source.rb |   20 +++++++-------------
 spec/unit/type/file.rb         |   12 ++++++++++++
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb
index 0d21712..a9ddc2d 100755
--- a/lib/puppet/type/file/ensure.rb
+++ b/lib/puppet/type/file/ensure.rb
@@ -138,11 +138,6 @@ module Puppet
         # We have to treat :present specially, because it works with any
         # type of file.
         def insync?(currentvalue)
-            if property = @resource.property(:source) and ! property.described?
-                warning "No specified sources exist"
-                return true
-            end
-
             if self.should == :present
                 if currentvalue.nil? or currentvalue == :absent
                     return false
diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb
index 1b0dd31..f2704ab 100755
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@ -135,18 +135,8 @@ module Puppet
             return args
         end
         
-        # Have we successfully described the remote source?
-        def described?
-            ! @stats.nil? and ! @stats[:type].nil? #and @is != :notdescribed
-        end
-        
         # Use the info we get from describe() to check if we're in sync.
         def insync?(currentvalue)
-            unless described?
-                warning "No specified sources exist"
-                return true
-            end
-
             if currentvalue == :nocopy
                 return true
             end
@@ -180,7 +170,11 @@ module Puppet
         def pinparams
             [:mode, :type, :owner, :group]
         end
-        
+
+        def found?
+            ! (@stats.nil? or @stats[:type].nil?)
+        end
+
         # This basically calls describe() on our file, and then sets all
         # of the local states appropriately.  If the remote file is a normal
         # file then we set it to copy; if it's a directory, then we just mark
@@ -202,8 +196,8 @@ module Puppet
                 }
             end
 
-            if @stats.nil? or @stats[:type].nil?
-                return nil # :notdescribed
+            if !found?
+                raise Puppet::Error, "No specified source was found from" + 
@should.inject("") { |s, source| s + " #{source},"}.gsub(/,$/,"")
             end
             
             case @stats[:type]
diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb
index 12b806d..f0ae70c 100755
--- a/spec/unit/type/file.rb
+++ b/spec/unit/type/file.rb
@@ -31,6 +31,18 @@ describe Puppet::Type.type(:file) do
         end
     end
 
+    describe "when specifying a source" do
+        before do
+            @file[:source] = "/bar"
+        end
+
+        it "should raise if source doesn't exist" do
+            @file.property(:source).expects(:found?).returns(false)
+            lambda { @file.retrieve }.should raise_error(Puppet::Error)
+        end
+
+    end
+
     describe "when retrieving remote files" do
         before do
             @filesource = Puppet::Type::File::FileSource.new
-- 
1.5.3.7


--~--~---------~--~----~------------~-------~--~----~
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