Recover_from_tombstone typeerror

On a site I just imported, a bunch (all?) of the images have been moved to tombstone.

When I run

cd /var/discourse
./launcher enter app
rake --trace uploads:recover_from_tombstone

I get this:

# rake --trace uploads:recover_from_tombstone
** Invoke uploads:recover_from_tombstone (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute uploads:recover_from_tombstone
        1 / 4918 (  0.0%)
        2 / 4918 (  0.0%)
Restoring /var/www/discourse/public/uploads/tombstone/default/original/2X/f/fa072fd9a4293c944d8a302758851ff73b2650c7.jpg...rake aborted!
TypeError: no implicit conversion of Symbol into Integer
/var/www/discourse/lib/upload_creator.rb:187:in `[]'
/var/www/discourse/lib/upload_creator.rb:187:in `should_crop?'
/var/www/discourse/lib/upload_creator.rb:49:in `block in create_for'
/var/www/discourse/lib/distributed_mutex.rb:21:in `synchronize'
/var/www/discourse/lib/distributed_mutex.rb:5:in `synchronize'
/var/www/discourse/lib/upload_creator.rb:35:in `create_for'
/var/www/discourse/lib/tasks/uploads.rake:441:in `block (4 levels) in recover_from_tombstone'
/var/www/discourse/lib/tasks/uploads.rake:440:in `open'
/var/www/discourse/lib/tasks/uploads.rake:440:in `block (3 levels) in recover_from_tombstone'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/nokogiri-1.8.0/lib/nokogiri/xml/node_set.rb:190:in `block in each'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/nokogiri-1.8.0/lib/nokogiri/xml/node_set.rb:189:in `upto'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/nokogiri-1.8.0/lib/nokogiri/xml/node_set.rb:189:in `each'
/var/www/discourse/lib/tasks/uploads.rake:428:in `block (2 levels) in recover_from_tombstone'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/relation/delegation.rb:46:in `each'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/relation/delegation.rb:46:in `each'
/var/www/discourse/lib/tasks/uploads.rake:424:in `block in recover_from_tombstone'
/var/www/discourse/lib/tasks/uploads.rake:420:in `each'
/var/www/discourse/lib/tasks/uploads.rake:420:in `each_with_index'
/var/www/discourse/lib/tasks/uploads.rake:420:in `recover_from_tombstone'
/var/www/discourse/lib/tasks/uploads.rake:401:in `block (2 levels) in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rails_multisite-1.0.6/lib/rails_multisite/connection_management.rb:126:in `block in each_connection'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rails_multisite-1.0.6/lib/rails_multisite/connection_management.rb:124:in `each'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rails_multisite-1.0.6/lib/rails_multisite/connection_management.rb:124:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:401:in `block in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
bin/rake:4:in `<top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/cli/exec.rb:74:in `load'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/cli/exec.rb:27:in `run'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/cli.rb:360:in `exec'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/cli.rb:20:in `dispatch'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/cli.rb:10:in `start'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/exe/bundle:35:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.4.0/gems/bundler-1.15.1/exe/bundle:27:in `<top (required)>'
/usr/local/bin/bundle:22:in `load'
/usr/local/bin/bundle:22:in `<main>'
Tasks: TOP => uploads:recover_from_tombstone

I’ve tried adding some tests to keep it from doing that, but they’ve all failed. Is there something obvious here?

UploadCreator expects opts = {}, but it’s being passed the integer file size. @zogstrip–I think that this might be related to the refactoring you did a while back. I stopped it from passing size instead of opts, but then I get NoMethodError: undefined method persisted?’ for #UploadCreator:0x00561e478a1ba8. It looks like UploadCreator.new is not passing back an Upload`, I guess.

https://github.com/discourse/discourse/blob/master/lib/upload_creator.rb#L187

https://github.com/discourse/discourse/blob/master/lib/upload_creator.rb#L35-L52

Any thoughts @zogstrip?

1 Like

Just pushed a fix

https://github.com/discourse/discourse/commit/94cee37eddfb20289b7877f56c7bb27da96d647d

3 Likes

Thanks, @zogstrip!

Sigh. I swear I tried exactly that and got another error, but it’s working now.

See also:

https://github.com/discourse/discourse/blob/94cee37eddfb20289b7877f56c7bb27da96d647d/lib/tasks/uploads.rake#L151

1 Like

Thanks, fixed that one too :thumbsup:

https://github.com/discourse/discourse/commit/b7e66201098662377d690676dd724f91a8a21da5

6 Likes

This topic was automatically closed after 24 hours. New replies are no longer allowed.