8

私は、開発モードで実行されているRailsアプリケーションを持っています(sqliteデータベースを使用)。このアプリケーションの目的は、ユーザーがJavaクライアントを介してファイルをアップロードできるようにすることです。

ユーザーがフォルダをアップロードしたい場合、その中のすべてのファイルが再帰的にアップロードされます。ユーザーがファイルをアップロードしたい場合、ファイルは通常どおりアップロードされます。

これが私が受け取っているエラーです:


 IOError

    in UploadedFilesController#new

closed stream

アプリケーションのトレースは次のとおりです。


/usr/lib/ruby/1.8/tempfile.rb:167:in `close'
/usr/lib/ruby/1.8/tempfile.rb:167:in `callback'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `call'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `method_added'
app/controllers/uploaded_files_controller.rb:114
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_without_new_constant_marking'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_file'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:202:in `load_file'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:94:in `require_or_load'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:248:in `load_missing_constant'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in `const_missing'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/inflector.rb:257:in `constantize'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/string/inflections.rb:148:in `constantize'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1426:in `recognize'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in `service'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/commands/servers/webrick.rb:66
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39

フレームワークのトレースは次のとおりです。


/usr/lib/ruby/1.8/tempfile.rb:167:in `close'
/usr/lib/ruby/1.8/tempfile.rb:167:in `callback'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `call'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `method_added'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in `handle_dispatch'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in `dispatch'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

これが完全なトレースです:


/usr/lib/ruby/1.8/tempfile.rb:167:in `close'
/usr/lib/ruby/1.8/tempfile.rb:167:in `callback'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `call'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb:85:in `method_added'
app/controllers/uploaded_files_controller.rb:114
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_without_new_constant_marking'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:203:in `load_file'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:202:in `load_file'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:94:in `require_or_load'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:248:in `load_missing_constant'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in `const_missing'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/inflector.rb:257:in `constantize'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/string/inflections.rb:148:in `constantize'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1426:in `recognize'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:112:in `handle_dispatch'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:in `dispatch'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/commands/servers/webrick.rb:66
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
/var/lib/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

なぜこれが発生するのかわかりません...このエラーが表示される前に、クライアントは約15〜30個のファイルをアップロードします(フォルダーから、Javaクライアントを介して)。Rails2.0.2を実行しています。データベースとしてsqliteを使用して開発モードで実行しているという事実がこれを引き起こす可能性がありますか?どんな助けでも大歓迎です!

みんなありがとう !

4

2 に答える 2

2

私はそれを理解したと思います、少なくとも私はそう思います(クライアントは今アップロードを続け、エラーはありません)。アップロードしたファイルからデータを読み取った後、それも閉じる必要があります。誰が考えただろうか?:P

于 2009-05-02T23:25:38.663 に答える
2

Railsアプリケーションでこれと同じ問題が発生しましたが、ファイルオブジェクトを閉じるだけでは機能しませんでした(Paperclipを使用すると、ファイルが閉じられます)。私はそれを修正したTempfileクラスへのモンキーパッチを開発し、Rails初期化子として使用します。

http://github.com/jwinky/ruby_tempfile_ioerrorから取得できます

于 2011-02-04T20:28:45.610 に答える