lib/auto-ali-cdn/oss.rb in 2cdn-0.1.4 vs lib/auto-ali-cdn/oss.rb in 2cdn-0.1.5
- old
+ new
@@ -66,11 +66,11 @@
Dir.foreach(res_path) do |name|
next if name =~ /^(\.)|(\.\.)$/
file_path = res_path+"/#{name}"
file_md5 = Digest::MD5.hexdigest(File.read(file_path))
res_type = res_path.gsub(/^.*\//, '')
- suffix = name.split(/\./).last
+ suffix = "."+name.split(/\./).last
object_key = config.site_resource_path+"/#{res_type}/#{name.gsub(/#{suffix}$/, "-#{file_md5}#{suffix}")}"
if bucket.object_exists?(object_key)
puts "#{name} --> #{object_key}".color(:dimgray)
replace_res_path.call(res_type+'/'+name, config.domain_name+'/'+object_key)
else
@@ -112,10 +112,10 @@
Dir.foreach(res_path) do |name|
next if name =~ /^(\.)|(\.\.)$/
file_path = res_path+"/#{name}"
file_md5 = Digest::MD5.hexdigest(File.read(file_path))
res_type = res_path.gsub(/^.*\//, '')
- suffix = name.split(/\./).last
+ suffix = "."+name.split(/\./).last
object_key = config.site_resource_path+"/#{res_type}/#{name.gsub(/#{suffix}$/, "-#{file_md5}#{suffix}")}"
if bucket.object_exists?(object_key)
replace_res_path.call(config.domain_name+'/'+object_key, res_type+'/'+name)
puts "#{object_key.color(:red)} --> #{"#{res_type}/#{name}".color(:cyan)}"
end