Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

Re-work identifier to avoid a custom SHA1 identifier. #1

Open
richardkmichael opened this issue May 11, 2012 · 0 comments
Open

Re-work identifier to avoid a custom SHA1 identifier. #1

richardkmichael opened this issue May 11, 2012 · 0 comments

Comments

@richardkmichael
Copy link
Owner

We compute a SHA1 as the identifier because we can't use a filename (.find_by_filename!()), because the filename won't necessarily be unique.

CarrierWave uses a before_save callback to invoke write_identifier: https://github.com/jnicklas/carrierwave/blob/master/lib/carrierwave/orm/activerecord.rb#L29

Because it's a before_save, the file has not been saved and we can't use the carrier_wave_files table ID as the identifier.

(What about giving the file to the storage engine, and receiving an identifier in return? E.g. Call store! and write_identifier in the before_save callback; or call write_identifier in an after_save callback?)

Or, use the filename as the identifier and change retrieval to use the associated model as well (e.g. identifier is effectively filename + model). However, this requires storing the model name and ID in the carrier_wave_files table (otherwise, we won't have any model information to join on).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant