#9 new
Michael Vastola

Scribd Stuck in Endless Loop

Reported by Michael Vastola | October 9th, 2010 @ 01:55 AM

Comments and changes to this ticket

  • Michael Vastola

    Michael Vastola October 9th, 2010 @ 02:06 AM

    Sorry.. I totally submitted that before writing anything...

    So what's happening is after doing a major overhaul of my site's code, and reimplementing scribd_fu with the latest version and Paperclip, whenever I go to save something or upload something to scribd, scribd_fu gets caught in an endless loop and saves a gazillion copies of the file to scribd.

    From my debugging, it seems like somehow scribd is triggering the after_save :upload_to_scribd callback on itself. No one else seems to be complaining about this bug though...

    Here's a sample stack trace from Eclipse:

    ipaper-test.rb [Ruby Application]

    Ruby
        Ruby Thread - 1 (Step end at /var/lib/gems/1.8/gems/scribd_fu-2.0.9/lib/scribd_fu.rb:70)    
            /var/lib/gems/1.8/gems/scribd_fu-2.0.9/lib/scribd_fu.rb:70  
            /var/lib/gems/1.8/gems/scribd_fu-2.0.9/lib/scribd_fu.rb:189 
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:178  
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:178  
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:166  
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:93   
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:92   
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:92   
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:276  
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:344    
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:251    
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2573    
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/validations.rb:1090 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/dirty.rb:79 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:229 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:229 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:182 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:228 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2664    
            /var/lib/gems/1.8/gems/scribd_fu-2.0.9/lib/scribd_fu.rb:70  
            /var/lib/gems/1.8/gems/scribd_fu-2.0.9/lib/scribd_fu.rb:189 
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:178  
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:178  
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:166  
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:93   
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:92   
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:92   
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:276  
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:344    
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:251    
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2573    
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/validations.rb:1090 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/dirty.rb:79 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:229 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:229 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:182 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:228 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2664    
            /var/lib/gems/1.8/gems/scribd_fu-2.0.9/lib/scribd_fu.rb:70  
            /var/lib/gems/1.8/gems/scribd_fu-2.0.9/lib/scribd_fu.rb:189 
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:178  
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:178  
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:166  
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:93   
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:92   
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:92   
            /var/lib/gems/1.8/gems/activesupport-2.3.8/lib/active_support/callbacks.rb:276  
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:344    
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/callbacks.rb:251    
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/base.rb:2573    
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/validations.rb:1090 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/dirty.rb:79 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:229 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:229 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:182 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:228 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196 
            /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/transactions.rb:196 
            /var/rails/XXXXXXXXXXXXXX/trunk/ipaper-test.rb:9    
    /usr/bin/ruby (Oct 9, 2010 1:44:38 AM)
    

    ipaper-test.rb contains:

    !/usr/bin/env ruby

    ENV['RAILS_ENV'] = 'development'
    require File.dirname(FILE) + '/config/boot'
    Rails.boot!
    require "#{RAILS_ROOT}/config/environment"

    r = SomeModel.first
    r.menu = File.open('/tmp/myfile.pdf')
    r.save


    Everything saves fine if I comment out:

    has_ipaper_and_uses 'Paperclip'

    Any idea what's going on? I'm totally stumped.. Everything used to work perfectly...

  • Michael Vastola

    Michael Vastola October 17th, 2010 @ 03:03 AM

    FYI, I fixed this problem with the following patch.

    --- /var/lib/gems/1.8/gems/scribd_fu-2.0.9/lib/scribd_fu.rb  2010-10-07 22:29:53.000000000 -0400
    +++ vendor/plugins/scribd_fu/lib/scribd_fu.rb   2010-10-17 02:59:08.000000000 -0400
    @@ -180,13 +180,17 @@
     
         def self.included(base)
           base.extend ClassMethods
    +           @in_scribd_fu_upload = false
         end
     
         # Upload the associated file to Scribd for iPaper conversion
         # This is called +after_save+ and cannot be called earlier,
         # so don't get any ideas.
         def upload_to_scribd
    +           return if @in_scribd_fu_upload
    +           @in_scribd_fu_upload = true
           ScribdFu::upload(self, file_path) if scribdable?
    +           @in_scribd_fu_upload = false
         end
     
         # Checks whether the associated file is convertable to iPaper
    

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

A Ruby on Rails plugin that streamlines interaction with Scribd.com’s iPaper service, and works along side of either Attachment_fu or Paperclip.

People watching this ticket

Referenced by

Pages