Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion lib/fakes3/file_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def initialize(root)
@bucket_hash = {}
Dir[File.join(root,"*")].each do |bucket|
bucket_name = File.basename(bucket)
bucket_obj = Bucket.new(bucket_name,Time.now,[])
puts "root bucket: #{bucket_name}"
bucket_obj = Bucket.new(bucket_name,Time.now, get_objects(bucket_name, bucket))
@buckets << bucket_obj
@bucket_hash[bucket_name] = bucket_obj
end
Expand Down Expand Up @@ -278,5 +279,24 @@ def create_metadata(content,request)
end
return metadata
end
private
def get_objects bucket_name, path, root_path=nil
if root_path.nil?
root_path = path
end

objects = []
if File.directory?(path)
Dir.new(path).each do |pathname|
next if ['.', '..'].include?(pathname)
if pathname == SHUCK_METADATA_DIR
objects << get_object(bucket_name, path[root_path.length+1..-1], nil)
else
objects += get_objects(bucket_name, File.join(path, pathname), root_path)
end
end
end
return objects
end
end
end