Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paperclip: copy_to_local_file called upon every update (of unrelated attributes)

I'm using paperclip 4.1.0 with Amazon S3. I was wondering why requests were so slow and found that "copy_to_local_file" is called whenever I am updating attributes of a model with an attachment, even if it's just one attribute unrelated to the attachment (in my case, a cache_count, which means that every time someone votes an instance up, the attachment is downloaded locally!).

I understand it is used in case a rollback is required, but it seems overkill when the attribute isn't directly related to the attachment.

Am I using paperclip in the wrong way or is it something that could be improved ?

Thanks for your help

like image 673
Arnaud Avatar asked Feb 25 '14 10:02

Arnaud


2 Answers

Just my 2 cents: the attachment gets downloaded locally only after ActiveRecord::Base#save is called.

  1. Would calling the 'base#save' in a cron on a daily basis instead help with the load?
  2. Otherwise, either remove the calling of method copy_to_local_file if possible
  3. or editing the source of paperclip's method of copy_to_local_file(style, local_dest_path) to exclude the downloading of attachment.
like image 53
George Avatar answered Nov 18 '22 08:11

George


This was an issue with paperclip, it's fixed on the master branch!

like image 44
Arnaud Avatar answered Nov 18 '22 07:11

Arnaud