Forum: JRuby tempfile unlink

701f3fd7de1c50b039c7591491ea97ab?d=identicon&s=25 Tristan Hill (Guest)
on 2014-04-01 11:07
(Received via mailing list)
Hi,

I'm getting this warning from jruby:

jruby/1.9/gems/mechanize-2.7.3/lib/mechanize/http/agent.rb:1218
warning: Tempfile#unlink or delete called on open file; ignoring

mechanisze does this:

  def make_tempfile name
    io = Tempfile.new name
    io.unlink
    io.binmode if io.respond_to? :binmode
    io
  end

I raised a bug with mechanize
(https://github.com/sparklemotion/mechanize/issues/371) thinking it
might be ill advised usage.  Having looked at the bug for the warning
(https://jira.codehaus.org/browse/JRUBY-6688) it seems to only be a
precaution against certain file methods (e.g. stat) not working, so
should be fine if such methods aren't used.

Any recommendations?

Thanks
Tristan
Bec38d63650c8912b6ba9b557fb953b9?d=identicon&s=25 Roger Pack (rogerdpack)
on 2014-05-06 21:50
Seems it's actually an "almost expected" behavior in windows [according
to
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/tempfi...
you *should* write it this way and in POSIX land it will work, and in
windows, gracefully not work].

However, it is annoying that apparently this is "the right use" but
spits out an annoying warning message in windows...I wonder if something
could be done there...
-roger-
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.