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
Labels
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 invokewrite_identifier
: https://github.com/jnicklas/carrierwave/blob/master/lib/carrierwave/orm/activerecord.rb#L29Because it's a
before_save
, the file has not been saved and we can't use thecarrier_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!
andwrite_identifier
in thebefore_save
callback; or callwrite_identifier
in anafter_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).The text was updated successfully, but these errors were encountered: