[#2180] Iterate over storage keys rather than blobs

To create less confusion on dev
This commit is contained in:
Frederic Merizen 2018-12-07 13:45:23 +01:00
parent c6c8bea095
commit 907e87809b
3 changed files with 43 additions and 25 deletions

View file

@ -81,12 +81,24 @@ module Cellar
end
def list_prefixed(prefix)
request = Net::HTTP::Get.new("/?prefix=#{prefix}")
@signer.sign(request, "")
response = @http.request(request)
if response.is_a?(Net::HTTPSuccess)
parse_bucket_listing(response.body)
end
result = []
marker = ''
begin
request = Net::HTTP::Get.new("/?prefix=#{prefix}&marker=#{marker}")
@signer.sign(request, "")
response = @http.request(request)
if response.is_a?(Net::HTTPSuccess)
(listing, truncated) = parse_bucket_listing(response.body)
result += listing
marker = listing.last
else
# TODO: error handling
return nil
end
end while truncated
result
end
def delete_keys(keys)
@ -126,9 +138,11 @@ module Cellar
def parse_bucket_listing(bucket_listing_xml)
doc = Nokogiri::XML(bucket_listing_xml)
doc
listing = doc
.xpath('//xmlns:Contents/xmlns:Key')
.map(&:text)
truncated = doc.xpath('//xmlns:IsTruncated').text == 'true'
[listing, truncated]
end
def bulk_deletion_request_body(keys)