Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 48f5d6513d69b72dc68472df0f5a27135d72ebf8 1 parent 8830399
@tobias tobias authored
Showing with 7 additions and 13 deletions.
  1. +2 −13 gems/vfs/lib/torquebox/vfs/ext/dir.rb
  2. +5 −0 gems/vfs/spec/dir_spec.rb
View
15 gems/vfs/lib/torquebox/vfs/ext/dir.rb
@@ -116,9 +116,6 @@ def foreach(path, &block)
private
def glob_one(pattern, flags=0, &block)
-
- is_absolute_vfs = false
-
#str_pattern = "#{pattern}"
str_pattern = pattern.to_str
@@ -135,23 +132,15 @@ def glob_one(pattern, flags=0, &block)
base = base_segments.join( '/' )
base.gsub!( /\\(.)/, '\1' )
-
- #if ( base.empty? || ( ::File.exist_without_vfs?( base ) && ! Java::OrgJbossVirtualPluginsContextJar::JarUtils.isArchive( base ) ) )
- #if ( base.empty? || ( ::File.exist_without_vfs?( base ) ) )
- #puts "doing FS glob"
- #paths = glob_before_vfs( str_pattern, flags, &block )
- #return paths
- #end
-
#puts "base= #{base}"
-
+
vfs_url, child_path = TorqueBox::VFS.resolve_within_archive( base )
#puts "vfs_url=#{vfs_url}"
#puts "child_path=#{child_path}"
return [] if vfs_url.nil?
#puts "segments.size==base_segments.size? #{segments.size == base_segments.size}"
- return [ base ] if segments.size == base_segments.size
+ return [ base ] if segments.size == base_segments.size && File.exists?( base )
matcher_segments = segments - base_segments
matcher = matcher_segments.join( '/' )
View
5 gems/vfs/spec/dir_spec.rb
@@ -79,6 +79,11 @@
items.should include( "#{prefix}/dotfiles/.four" )
end
+ it "should not find non-existent files" do
+ items = Dir.glob( "#{prefix}/home/larry/not-there.txt" )
+ items.should be_empty
+ end
+
it "should allow globbing without any special globbing characters on normal files" do
items = Dir.glob( "#{prefix}/home/larry" )
items.should_not be_empty

0 comments on commit 48f5d65

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