7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/models/effective/delayed_job.rb', line 7
def process_asset(obj)
if obj.kind_of?(Effective::Asset)
asset = obj
else
asset = Effective::Asset.where(:id => (obj.to_i rescue 0)).first
end
if asset.present? && !asset.processed? && asset.upload_file.present? && asset.upload_file != 'placeholder'
puts "Processing asset ##{asset.id} from #{asset.upload_file}."
if asset.upload_file.include?(Effective::Asset.string_base_path)
puts "String-based Asset processing and uploading..."
asset.data.cache_stored_file!
asset.data.retrieve_from_cache!(asset.data.cache_name)
asset.data.recreate_versions!
elsif asset.upload_file.include?(Effective::Asset.s3_base_path)
puts "S3 Uploaded Asset downloading and processing..."
asset.remote_data_url = asset.url if asset.image?
else
puts "Non S3 Asset downloading and processing..."
puts "Downloading #{asset.url}"
asset.remote_data_url = asset.upload_file
end
asset.processed = true
asset.save!
(GC.start rescue nil)
puts "Successfully processed the asset."
end
end
|