A part of me died when I read that.
> An obvious workaround is attached but surely the whole "if
> filesystem_has_posix_semantics?" block should be reworked or this should be
> followed up with the ruby core guys. While I'm not exactly sure whether we
> can consider closing the IO stream to a file before unlinking it a bug in
> itself, Tempfile#unlink now sure is inconsistent with File#unlink. Principle
> of least surprise? No, Sir!
>
> What do you guys think?
Thanks for the heads up, I just posted my thoughts on Redmine about this.
Hopefully the Ruby team is willing to fix it.
> [1] http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/23505
> [2] http://redmine.ruby-lang.org/issues/show/1494
> diff --git a/lib/rack/rewindable_input.rb b/lib/rack/rewindable_input.rb
> index accd96b..b4d1952 100644
> --- a/lib/rack/rewindable_input.rb
> +++ b/lib/rack/rewindable_input.rb
> @@ -74,7 +74,7 @@ module Rack
> @rewindable_io.chmod(0000)
> @rewindable_io.set_encoding(Encoding::BINARY) if @rewindable_io.respond_to?(:set_encoding)
> @rewindable_io.binmode
> - if filesystem_has_posix_semantics?
> + if filesystem_has_posix_semantics? && "#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}" < "1.9.1.152"
> @rewindable_io.unlink
> @unlinked = true
> end
If we have to go this route, what about just explicitly unlinking it?
I'm not going to go as far as undefining the finalizer that Tempfile
defines since the finalizer checks if the file exists before unlinking
anyways.
diff --git a/lib/rack/rewindable_input.rb b/lib/rack/rewindable_input.rb
index accd96b..fcd6d06 100644
--- a/lib/rack/rewindable_input.rb
+++ b/lib/rack/rewindable_input.rb
@@ -75,7 +75,7 @@ module Rack
@rewindable_io.set_encoding(Encoding::BINARY) if @rewindable_io.respond_to?(:set_encoding)
@rewindable_io.binmode
if filesystem_has_posix_semantics?
- @rewindable_io.unlink
+ File.unlink(@rewindable_io.path)
@unlinked = true
end
--
Eric Wong
2009/7/19 Eric Wong <normal...@yhbt.net>
>
> Thanks for the heads up, I just posted my thoughts on Redmine about this.
> Hopefully the Ruby team is willing to fix it.
Thanks for putting this to their attention.
I've updated the issue with links to the original discussion on
ruby-core in 2004. Both the its author and matz decided the patch, as
recently introduced, wouldn't be a good idea:
http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-core/2848?2697-2915+split-mode-vertical.
> If we have to go this route, what about just explicitly unlinking it?
> I'm not going to go as far as undefining the finalizer that Tempfile
> defines since the finalizer checks if the file exists before unlinking
> anyways.
I don't think any change in the rack codebase will be necessary as I
fully expect this to be fixed in Ruby before the next release.
Considering that many people are even still using 1.8 I don't think
too many compile from trunk or any other svn branch for that matter.
Those who do would probably check the list here when in trouble, no?
Cheers,
Niels
Will report back here.
- Niels.
[1] http://redmine.ruby-lang.org/issues/show/1494
2009/7/22 Hongli Lai <hon...@phusion.nl>:
How about heavily advocating for upstream to accept the fix?
Perhaps they didn't get the message. Try another post to ruby-core.
jeremy
2009/8/21 Jeremy Kemper <jer...@bitsweat.net>:
>> OK, that's it. I've forked Tempfile:
>>
>> http://better.rubyforge.org/
>>
>> Anybody object on making Rack depend on this library?
>>
>
> How about heavily advocating for upstream to accept the fix?
>
> Perhaps they didn't get the message. Try another post to ruby-core.
I agree with Jeremy (I don't understand the problem except Rack has trouble
because of r23494, but Matz also doesn't seem to know the problem.)
Thanks,
Masayoshi Takahashi