Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directories with trailing slash do not work #26

Closed
rfdonnelly opened this issue Dec 28, 2016 · 2 comments
Closed

Directories with trailing slash do not work #26

rfdonnelly opened this issue Dec 28, 2016 · 2 comments

Comments

@rfdonnelly
Copy link

MemFs::FileSystem::find does not support directories with trailing slashes.

Example

Giving Dir.entries a path with a trailing slash works without MemFs but blows up with MemFs.

require 'memfs'

def test
  FileUtils.mkdir_p('/tmp/a/b/c')
  puts Dir.entries('/tmp/a/').to_s
  FileUtils.rm_r('/tmp/a')
end

puts 'Without MemFs'
test

puts 'With MemFs'
MemFs.activate { test }

Output

$ ruby memfs_trailing_slash.rb
Without MemFs
["..", "b", "."]
With MemFs
/var/lib/gems/2.3.0/gems/memfs-0.5.0/lib/memfs/file_system.rb:64:in `find!': No such file or directory - /tmp/a/ (Errno::ENOENT)
        from /var/lib/gems/2.3.0/gems/memfs-0.5.0/lib/memfs/file_system.rb:68:in `find_directory!'
        from /var/lib/gems/2.3.0/gems/memfs-0.5.0/lib/memfs/file_system.rb:50:in `entries'
        from /var/lib/gems/2.3.0/gems/memfs-0.5.0/lib/memfs/dir.rb:30:in `entries'
        from memfs_trailing_slash.rb:5:in `test'
        from memfs_trailing_slash.rb:13:in `block in <main>'
        from /var/lib/gems/2.3.0/gems/memfs-0.5.0/lib/memfs.rb:53:in `activate'
        from memfs_trailing_slash.rb:13:in `<main>'
@simonc
Copy link
Owner

simonc commented Dec 28, 2016

Hey @rfdonnelly !
Thanks for reporting this issue. It's indeed annoying. I started looking into it but it's a pandora box since I have to write specs and code for the various methods that could be impacted (and I have to deal with symlinks too).

It's not a complicated fix, it just takes time to do all of it ☺️

@simonc
Copy link
Owner

simonc commented Jan 1, 2017

@rfdonnelly actually I was wrong, the impact of a trailing / is apparently null so simply ignoring it seems to do the trick. I will push the fix in a few minutes 😉

@simonc simonc closed this as completed in da103bb Jan 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants