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.
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 requestsIt 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 theattr_reader :file
with a new method#file
that willretrieve_from_store!
when accessed, but only a maximum X times as defined in the configuration fordownload_retries
before it just returns@file
even if it's nil.