Skip to content
This repository
Browse code

Don't glob files that don't exist [TORQUE-461]

  • Loading branch information...
commit 48f5d6513d69b72dc68472df0f5a27135d72ebf8 1 parent 8830399
Toby Crawley authored June 20, 2011
15  gems/vfs/lib/torquebox/vfs/ext/dir.rb
@@ -116,9 +116,6 @@ def foreach(path, &block)
116 116
     private
117 117
 
118 118
     def glob_one(pattern, flags=0, &block)
119  
-
120  
-      is_absolute_vfs = false
121  
-
122 119
       #str_pattern = "#{pattern}"
123 120
       str_pattern = pattern.to_str
124 121
 
@@ -135,23 +132,15 @@ def glob_one(pattern, flags=0, &block)
135 132
       base = base_segments.join( '/' )
136 133
 
137 134
       base.gsub!( /\\(.)/, '\1' )
138  
-
139  
-      #if ( base.empty? || ( ::File.exist_without_vfs?( base ) && ! Java::OrgJbossVirtualPluginsContextJar::JarUtils.isArchive( base ) ) )
140  
-      #if ( base.empty? || ( ::File.exist_without_vfs?( base ) ) )
141  
-        #puts "doing FS glob"
142  
-        #paths = glob_before_vfs( str_pattern, flags, &block )
143  
-        #return paths
144  
-      #end
145  
-
146 135
       #puts "base= #{base}"
147  
-
  136
+      
148 137
       vfs_url, child_path = TorqueBox::VFS.resolve_within_archive( base )
149 138
       #puts "vfs_url=#{vfs_url}"
150 139
       #puts "child_path=#{child_path}"
151 140
 
152 141
       return []       if vfs_url.nil?
153 142
       #puts "segments.size==base_segments.size? #{segments.size == base_segments.size}"
154  
-      return [ base ] if segments.size == base_segments.size
  143
+      return [ base ] if segments.size == base_segments.size && File.exists?( base )
155 144
 
156 145
       matcher_segments = segments - base_segments
157 146
       matcher = matcher_segments.join( '/' )
5  gems/vfs/spec/dir_spec.rb
@@ -79,6 +79,11 @@
79 79
         items.should include( "#{prefix}/dotfiles/.four" )
80 80
       end
81 81
 
  82
+      it "should not find non-existent files" do
  83
+        items = Dir.glob( "#{prefix}/home/larry/not-there.txt" )
  84
+        items.should be_empty
  85
+      end
  86
+      
82 87
       it "should allow globbing without any special globbing characters on normal files" do
83 88
         items = Dir.glob( "#{prefix}/home/larry" )
84 89
         items.should_not be_empty

0 notes on commit 48f5d65

Please sign in to comment.
Something went wrong with that request. Please try again.