lib/fakes3/file_store.rb in fakes3-1.2.0 vs lib/fakes3/file_store.rb in fakes3-1.2.1

- old
+ new

@@ -94,10 +94,11 @@ real_obj.size = metadata.fetch(:size) { 0 } real_obj.creation_date = File.ctime(obj_root).utc.iso8601(SUBSECOND_PRECISION) real_obj.modified_date = metadata.fetch(:modified_date) do File.mtime(File.join(obj_root, "content")).utc.iso8601(SUBSECOND_PRECISION) end + real_obj.cache_control = metadata[:cache_control] real_obj.custom_metadata = metadata.fetch(:custom_metadata) { {} } return real_obj rescue unless @quiet_mode puts $! @@ -156,10 +157,11 @@ obj.content_type = src_metadata[:content_type] obj.content_disposition = src_metadata[:content_disposition] obj.content_encoding = src_metadata[:content_encoding] # if src_metadata[:content_encoding] obj.size = src_metadata[:size] obj.modified_date = src_metadata[:modified_date] + obj.cache_control = src_metadata[:cache_control] src_bucket.find(src_name) dst_bucket.add(obj) return obj end @@ -212,10 +214,11 @@ obj.content_type = metadata_struct[:content_type] obj.content_disposition = metadata_struct[:content_disposition] obj.content_encoding = metadata_struct[:content_encoding] # if metadata_struct[:content_encoding] obj.size = metadata_struct[:size] obj.modified_date = metadata_struct[:modified_date] + obj.cache_control = metadata_struct[:cache_control] bucket.add(obj) return obj rescue unless @quiet_mode @@ -267,17 +270,39 @@ $!.backtrace.each { |line| puts line } return nil end end + def delete_objects(bucket, objects, request) + begin + filenames = [] + objects.each do |object_name| + filenames << File.join(@root,bucket.name,object_name) + object = bucket.find(object_name) + bucket.remove(object) + end + + FileUtils.rm_rf(filenames) + rescue + puts $! + $!.backtrace.each { |line| puts line } + return nil + end + end + # TODO: abstract getting meta data from request. def create_metadata(content, request) metadata = {} metadata[:md5] = Digest::MD5.file(content).hexdigest metadata[:content_type] = request.header["content-type"].first if request.header['content-disposition'] metadata[:content_disposition] = request.header['content-disposition'].first end + + if request.header['cache-control'] + metadata[:cache_control] = request.header['cache-control'].first + end + content_encoding = request.header["content-encoding"].first metadata[:content_encoding] = content_encoding #if content_encoding # metadata[:content_encoding] = content_encoding #end