Proposal - Hash salt for :hash_data option?

31 views
Skip to first unread message

Winston Kotzan

unread,
Apr 25, 2013, 1:06:25 PM4/25/13
to papercli...@googlegroups.com
I don't like using :updated_at as a criteria for generating the filename hash.  It becomes problematic when adding new styles because when you call reprocess!(:new_style_name), the image_updated_at value gets updated and screws up the hash key for your existing styles.  I like how updated_at could be used as a switch to change the hash when you update the photo, but I don't like how it is vulnerable to change unintentionally.  I propose creating a :hash_salt value in the database which would consist of a randomly generated text string.  This would have an advantage over :updated_at because it would only change when you tell it to.

I'm thinking about forking a branch and adding a method to randomly generate the string, generate_hash_salt(length), where length would be the length of the randomly generated hash salt string.   This method would be called every time you create a new attachment.  I haven't looked into exactly how I would implement yet, but I plan to add code so that you can just set your Paperclip options[:hash_data] value to ':class/:attachment/:id/:style/:hash_salt' in order to use the salt instead of updated_at.

What do you think of this idea?  Has it been proposed by anyone yet?

-Winston
Reply all
Reply to author
Forward
0 new messages