Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Fix list-objects returning nothing after restarting #221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
23 changes: 22 additions & 1 deletion lib/fakes3/file_store.rb
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ 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,[])
bucket_obj = Bucket.new(bucket_name, Time.now, get_objects(bucket_name, bucket))
@buckets << bucket_obj
@bucket_hash[bucket_name] = bucket_obj
end
@@ -278,5 +278,26 @@ 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