class Cws3chk::Checker
This class is in charge of checking the existance on S3 of the assets described by ActiveRecord + Carrierwave. It checks for the existence of the original file an the different versions. It stores the result of the check in Redis.
After loading the data from the database, it performs the calls to S3 in parallel via threads.
Public Instance Methods
check()
click to toggle source
# File lib/cws3chk/checker.rb, line 15 def check call_with_threads procs, number_of_threads: threads end
Private Instance Methods
iterate_over_resources_and_versions() { |resource, uploader, version| ... }
click to toggle source
# File lib/cws3chk/checker.rb, line 33 def iterate_over_resources_and_versions request.find_each do |resource| next unless resource.public_send("#{mounted_column}?") # resource.image? uploader = resource.public_send mounted_column # resource.image versions(uploader).each do |version| yield resource, uploader, version end end end
procs()
click to toggle source
# File lib/cws3chk/checker.rb, line 21 def procs [].tap do |_procs| iterate_over_resources_and_versions do |resource, uploader, version| _procs << Proc.new{ study resource, uploader, version } end end end
study(resource, uploader, version)
click to toggle source
# File lib/cws3chk/checker.rb, line 43 def study resource, uploader, version s3 = Cws3chk::S3.new uploader, version store = Cws3chk::Store.new( resource, mounted_column, version) if s3.file_exists? store.store_headers s3.headers else store.store_missing_asset end end
versions(uploader)
click to toggle source
# File lib/cws3chk/checker.rb, line 29 def versions uploader [nil] + uploader.versions.keys end