2009-05-02 6 views
8

Ho un'applicazione rails, in esecuzione in modalità di sviluppo (con un database SQLite). Lo scopo dell'applicazione è consentire agli utenti di caricare file attraverso un client java.cosa potrebbe causare questo rotaie ioerror closed stream?

Se un utente desidera caricare una cartella, tutti i file al suo interno verranno caricati in modo ricorsivo. Se un utente desidera caricare un file, il file verrà caricato normalmente.

Ecco l'errore che sto ricevendo:


IOError 

    in UploadedFilesController#new 

closed stream 

Ecco la traccia dell'applicazione:


/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 

Ecco la traccia quadro:


/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 

Ecco la traccia completa :


/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 

Non ho idea del perché questo accada ... il client arriva a caricare circa 15-30 file (da una cartella, attraverso il client java) prima che venga visualizzato questo errore. Sto usando Rails 2.0.2. Potrebbe il fatto che sto utilizzando la modalità di sviluppo usando sqlite come database? Qualsiasi aiuto sarebbe molto apprezzato !

Grazie ragazzi!

risposta

2

Penso di aver capito, almeno credo di farlo (il client continua a caricare ora, senza errori). Dopo aver letto i dati da un file che si carica, è necessario anche CLOSE. Chi l'avrebbe mai detto? : P

+1

ero d'accordo, ma sai perché quello che conta? Stai esaurendo lo spazio in qualche modo? –

+0

@JosephHolsten Buona domanda! Mi piacerebbe sapere lo stesso! –

2

Ci siamo imbattuti in questo stesso problema con la nostra applicazione Rails, anche se la semplice chiusura dell'oggetto file non ha funzionato per noi (usiamo Paperclip e chiude il file). Ho sviluppato un monkeypatch nella classe Tempfile che lo ha risolto per noi, e usiamo come inizializzatore Rails.

Si può afferrare da http://github.com/jwinky/ruby_tempfile_ioerror

+0

Grazie! Mi hai salvato un sacco di tempo. – weston

+0

Ho lo stesso problema. Ho usato la patch della scimmia dall'alto, ma non è stato d'aiuto. Altre idee? –