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

fix: dont retrieve from store until accessing file #2698

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Amnesthesia
Copy link

@Amnesthesia Amnesthesia commented Sep 6, 2023

Carrierwave seems to try retrieve_from_store! as soon as you access #uploaders, and if a file doesn't exist on S3 (for whatever reason), it will keep retrying over and over and over, making it virtually unusable because of the amounts of retried requests

It should be possible to access the uploader, and retrieve storage path and identifier without performing network requests to retrieve the file from storage, if retrieving the file isn't needed.

This PR removes retrieve_from_store! from the @uploaders ||= setup block and instead replaces the attr_reader :file with a new method #file that will retrieve_from_store! when accessed, but only a maximum X times as defined in the configuration for download_retries before it just returns @file even if it's nil.

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

Successfully merging this pull request may close these issues.

1 participant