Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not updating images when old and new filename are the same #2680

Closed
Complaex-Makandra opened this issue Jul 31, 2023 · 1 comment
Closed

Comments

@Complaex-Makandra
Copy link

When updating an image in Carrierwave with another image that shares the exact filename the association between the model and the image breaks and the image will no longer be shown.

The reason for this in my understanding is that the name in the store dir will morph into ...(2) but the reference in the model will still point on the file without the new assigned number.
poster(2)

What am I doing wrong?

A simple solution would be (reference):

 def filename
    if File.exist?(File.join(store_dir, file.filename)) && path != (File.join(store_dir, original_filename))
      @name ||= "#{File.basename(original_filename, '.*')}_#{Digest::MD5.hexdigest(original_filename).from(25)}"
      "#{@name}.#{file.extension}"
    else
      original_filename
    end
  end

But I dont think this should be necessary.

Im using Ubuntu: Linux 5.14.0-1059-oem x86_64

@Complaex-Makandra
Copy link
Author

Sorry I didn't see the other issue which seems to be exactly the same #2678

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

No branches or pull requests

1 participant