Skip to content

bugfix: when loop local directories, listObjects use request's prefix… #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/emulator/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module OssEmulator
# Log.fatal("something", 'red')
class Log

LOG_DEFAULT_DIR = "../log"
LOG_DEFAULT_DIR = "log"
LOG_DEFAULT_FILE = "#{LOG_DEFAULT_DIR}/emulator.log"
LOG_TEST_FILE = "#{LOG_DEFAULT_DIR}/test.log"
LOG_ALIYUN_SDK_FILE = "#{LOG_DEFAULT_DIR}/aliyun_sdk.log"
Expand Down
2 changes: 1 addition & 1 deletion lib/emulator/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def initialize(address, port, hostname, ssl_cert_path, ssl_key_path, extra_optio
)
rescue
webrick_config.merge!(
:Logger => WEBrick::Log.new(nil),
:Logger => WEBrick::Log.new(File.open(File::NULL, 'w')),
:AccessLog => []
)
end
Expand Down
14 changes: 6 additions & 8 deletions lib/emulator/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,22 @@ def self.valid_object_name(name)
def self.get_bucket_list_objects(lbr, req)
marker = req.query["marker"] ? req.query["marker"].to_s : nil
marker_found = (marker==nil || marker=="") ? true : false
prefix = req.query["prefix"] ? req.query["prefix"].to_s : nil
prefix = nil if prefix==""
prefix = req.query["prefix"] ? req.query["prefix"].to_s : ""

max_keys = req.query["max-keys"] ? req.query["max-keys"].to_i : 100
max_keys = max_keys>1000 ? 1000 : max_keys
delimiter = req.query["delimiter"] ? req.query["delimiter"].to_s : nil
delimiter = nil if delimiter==""

if delimiter
if prefix
base_prefix = prefix
else
base_prefix = ""
end
base_prefix = prefix
prefix_offset = base_prefix.length
end

bucket_path = File.join(Config.store, req.bucket, '/')
find_root_folder = bucket_path


find_root_folder = File.join(Config.store, req.bucket, prefix, '/')
object_list = []
common_prefix_list = []
is_truncated = false
Expand Down