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

Bad symlink should be mv'able by FileUtils #2153

Closed
headius opened this issue Nov 8, 2014 · 0 comments
Closed

Bad symlink should be mv'able by FileUtils #2153

headius opened this issue Nov 8, 2014 · 0 comments

Comments

@headius
Copy link
Member

@headius headius commented Nov 8, 2014

Here's the test that fails, from test_fileutils.rb. It's the last 'mv'.

  def test_mv_symlink
    touch 'tmp/cptmp'
    # src==dest (2) symlink and its target
    File.symlink 'cptmp', 'tmp/cptmp_symlink'
    assert_raise(ArgumentError) {
      mv 'tmp/cptmp', 'tmp/cptmp_symlink'
    }
    assert_raise(ArgumentError) {
      mv 'tmp/cptmp_symlink', 'tmp/cptmp'
    }
    # src==dest (3) looped symlink
    File.symlink 'symlink', 'tmp/symlink'
    assert_raise(Errno::ELOOP) {
      mv 'tmp/symlink', 'tmp/symlink'
    }
    # unexist symlink
    File.symlink 'xxx', 'tmp/src'
    assert_nothing_raised {
      mv 'tmp/src', 'tmp/dest'
    }
    assert_equal true, File.symlink?('tmp/dest')
  end if have_symlink?

I'm guessing that somewhere within the guts of FileUtils, it calls methods in JRuby to actually move the file (by recopying it or by doing a filesystem move) and that logic is attempting to canonicalize the path through the bad symlink.

So, this is an interesting and perhaps not too difficult one to fix. Run with jruby test/mri/runner.rb mri/fileutils/test_fileutils.rb.

@headius headius added this to the JRuby 9.0.0.0 milestone Nov 8, 2014
@headius headius removed this from the JRuby 9.0.0.0 milestone Jan 16, 2015
@headius headius added this to the JRuby 9.0.0.0-pre1 milestone Jan 16, 2015
@headius headius added this to the JRuby 9.0.0.0-pre1 milestone Jan 16, 2015
@headius headius removed this from the JRuby 9.0.0.0 milestone Jan 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant