mirror of
https://github.com/kemko/paperclip.git
synced 2026-01-06 10:25:40 +03:00
Don't perform API request for .exist? of synced files
This commit is contained in:
@@ -101,9 +101,11 @@ module Paperclip
|
||||
raise '#path is not available for this type of storage, use #to_file instead'
|
||||
end
|
||||
|
||||
# By default checks main store if synced and cache otherwise.
|
||||
# Checks if attached file exists. When store_id is not given
|
||||
# it uses fast check and does not perform API request for synced files
|
||||
def exists?(style = default_style, store_id = nil)
|
||||
store_id ||= synced_to?(self.class.main_store_id) ? self.class.main_store_id : :cache
|
||||
return true if !store_id && synced_to?(self.class.main_store_id)
|
||||
store_id ||= :cache
|
||||
!self.class.directory_for(store_id).files.head(key(style)).nil?
|
||||
end
|
||||
|
||||
|
||||
@@ -113,9 +113,11 @@ module Paperclip
|
||||
create_tempfile(response.body) if response.is_a?(Net::HTTPOK)
|
||||
end
|
||||
|
||||
# By default checks main store if synced and cache otherwise.
|
||||
# Checks if attached file exists. When store_id is not given
|
||||
# it uses fast check and does not perform API request for synced files
|
||||
def exists?(style = default_style, store_id = nil)
|
||||
store_id ||= instance_read(:synced_to_s3) ? :s3 : :cache
|
||||
return true if !store_id && instance_read(:synced_to_s3)
|
||||
store_id ||= :cache
|
||||
case store_id
|
||||
when :cache
|
||||
File.exist?(filesystem_path(style))
|
||||
|
||||
Reference in New Issue
Block a user