jrgifford / delayed_paperclip

Process your Paperclip attachments in the background with delayed_job or Resque.
http://www.jstorimer.com/ruby/2010/01/30/delayed-paperclip.html
MIT License
402 stars 155 forks source link

Version 2.6.0.0 does not process non-delayed style #40

Closed jeremybdk closed 10 years ago

jeremybdk commented 11 years ago

Hello,

Since upgrading to the last version, it seems that all the style that are not delayed are not processed anymore, here is my setup :

 process_in_background :img, :only_process => [:large,:edit,:feed,:email,:comment_email,:thumb,:small]

I have all these styles and I have a medium style that I want to process imediatly so I left it out the process_in_background options. Since I updated my gem the medium style is not processed anymore by paperclip, if I add it to the process_in_background it's process in delay but if I don't include it this style is never processed.

I reverted to 2.5.1.0 and everything is working again as expected,

Thank you,

ScotterC commented 11 years ago

@jaybbb Thanks for the update. This test is currently passing. Which is what tests that functionality. Any light you could shed on this would be appreciated.

jeremybdk commented 11 years ago

I will retest everything and get back to you but thanks for your quick answer !

jeremybdk commented 11 years ago

That's my model file :

  has_attached_file :img, :styles => { :large => "1200x1200>", :medium => "800x800^", :feed => "189x189^", :email => "140x140^",:comment_email => "438x306^", :edit => "433x220^", :thumb => "80x80^", :small => "96x69^" ,:featured =>"380x281^" },
                          :convert_options => {:large => "-interlace Plane", :medium => "-gravity center -crop '800x800+0+0' -interlace Line", :feed => "-gravity center -crop '189x189+0+0' -interlace Line", :email => "-gravity center -crop '140x140+0+0' -interlace Line", :comment_email => "-gravity center -crop '438x306+0+0' -interlace Line", :edit => "-gravity center -crop '433x220+0+0' -interlace Line", :small => "-gravity center -crop '96x69+0+0' -interlace Line", :thumb => "-gravity center -crop '80x80+0+0' -interlace Line", :featured => "-gravity center -crop '380x281+0+0' -interlace Line" },
                          :default_url => "/defaults/avatar/:style/missing.png",
                          :url => ':s3_alias_url',
                          :s3_host_alias => 'dl3zix6ms0aea.cloudfront.net',
                          :path => ":class/:attachment/:id_partition/:style/:filename"

  process_in_background :img, :only_process => [:large,:feed,:email,:comment_email,:thumb,:small]

All these style are processed in bg : [:large,:feed,:email,:comment_email,:thumb,:small] but with the new gem none of the other style are processed ( medium for example is not processed)

Any idea what might be going on ?

Thanks,

jeremybdk commented 11 years ago

Actually I don't know what might be wrong it now seems that all the styles are processed only in background. What I am trying to achieve is to have some style processed at image upload and some other afterwards.

Thanks,

ScotterC commented 11 years ago

As I played around with the code today I'm pretty sure I found the source of the problem. Delayed Paperclip inherits the only_process option from Paperclips definitions. Move the only_process to the has_attached_file options and it'll work. I understand that this is probably not what you're going for but it's the current implementation. It won't require much to tweak the current library to do what you want though. It would require editing this method: https://github.com/jrgifford/delayed_paperclip/blob/master/lib/delayed_paperclip.rb#L54

ScotterC commented 11 years ago

I just realized my own comment must be wrong because it should overwrite those defaults in the method I linked. This test is passing so I'm a bit miffed. Maybe the options aren't getting set.

Could you bring up your console and look up YourModel.img.delayed_options and see if your options have gotten passed down?

jeremybdk commented 11 years ago

Here are the options that get passed down to my model :

{
            :priority => 0,
        :only_process => [
    [0] :large,
    [1] :feed,
    [2] :email,
    [3] :comment_email,
    [4] :thumb,
    [5] :small
],
 :url_with_processing => true,
:processing_image_url => "http://dl3zix6ms0aea.cloudfront.net/:class/:attachment/:id_partition/original/:filename"

}

ScotterC commented 11 years ago

The [0] before large and the other integers are surprising. Definitely wasn't expecting that. A quick test would be to write the same test as before but try it with multiple styles for only_process. Care to try your hand at it?

jeremybdk commented 11 years ago

The [0] is just a awesome print formatting. I could try but I am new to rails and still learning the basics.

But I will try to look at it and see if I can find something. Thanks

On 31 juil. 2013, at 19:14, "Scott Carleton" notifications@github.com<mailto:notifications@github.com> wrote:

The [0] before large and the other integers are surprising. Definitely wasn't expecting that. A quick test would be to write the same test as before but try it with multiple styles for only_process. Care to try your hand at it?

Reply to this email directly or view it on GitHubhttps://github.com/jrgifford/delayed_paperclip/issues/40#issuecomment-21878494.

haraldmartin commented 11 years ago

Anyone found a fix for this?

I have the same problem; I want some styles to be processed directly and some in the background using Delayed Job, but the current version only process the styles I set as background styles (and not really have time to get into the full source now).

jeremybdk commented 11 years ago

I tried but as I am still learning ruby I could not fix it

ethier commented 11 years ago

I can confirm this issue with both 2.5.1.0 and 2.6+. only_process does not appear to fall back and process those styles that you do not specify in the array. I've been digging through the code and, unless I'm missing something, shouldn't the reprocess_without_delay! be called for all of the styles that exist outside of the only_process array? I don't see that anywhere.

jrgifford commented 11 years ago

@ethier have you tried from git? I think that since #57 got merged in, it should work.

ethier commented 11 years ago

That was merged into the rails2 branch. I'm experiencing it with rails3. Or, are the branch names not reflective of the rails versions?

haraldmartin commented 11 years ago

+1, i'm also on Rails version 3, using the master branch and experiencing the same thing.

ketiko commented 11 years ago

:+1: Rails 4 using master branch has same problem.

jrgifford commented 11 years ago

Darnit. I was hoping this was fixed. :\

I'll try and investigate this weekend.

ethier commented 11 years ago

@jrgifford Any luck with this?

mikaelprag commented 11 years ago

+1, A fix to this problem would be invaluable.

Edit: I diffed the code from pull request #62 and that seems to have done the trick?

ScotterC commented 10 years ago

https://github.com/jrgifford/delayed_paperclip/pull/79 should fix this.