Fix migration script to work without dir objects
This commit is contained in:
parent
e6fa6ca586
commit
6b7bb8144e
@ -61,15 +61,18 @@ class Migrator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def work_on_dir(directory, parent_directory)
|
def work_on_dir(directory, parent_directory)
|
||||||
logger.debug "Retrieving listing for '#{parent_directory}#{directory}'"
|
full_directory = "#{parent_directory}#{directory}"
|
||||||
|
logger.debug "Retrieving listing for '#{full_directory}'"
|
||||||
|
|
||||||
listing = get_directory_listing_from_swift("#{parent_directory}#{directory}")
|
listing = get_directory_listing_from_swift("#{full_directory}")
|
||||||
|
|
||||||
|
logger.debug "Listing for '#{full_directory}': #{listing}"
|
||||||
|
|
||||||
if listing
|
if listing
|
||||||
listing.split("\n").each do |item|
|
listing.split("\n").each do |item|
|
||||||
if is_dir? item
|
if is_dir? item
|
||||||
# get dir listing and repeat
|
# get dir listing and repeat
|
||||||
work_on_dir(item, "#{parent_directory}")
|
work_on_dir(item, "#{parent_directory}") unless item == full_directory
|
||||||
else
|
else
|
||||||
copy_document("#{parent_directory}", item)
|
copy_document("#{parent_directory}", item)
|
||||||
end
|
end
|
||||||
@ -99,14 +102,10 @@ class Migrator
|
|||||||
|
|
||||||
get_response = nil
|
get_response = nil
|
||||||
|
|
||||||
do_head_request("#{url_for_directory(@username, directory)}") do |response|
|
if is_root_listing
|
||||||
return "" if response.code == 404
|
get_response = do_get_request("#{container_url_for(@username)}/?delimiter=/&prefix=")
|
||||||
|
else
|
||||||
if is_root_listing
|
get_response = do_get_request("#{container_url_for(@username)}/?delimiter=/&prefix=#{escape(directory)}")
|
||||||
get_response = do_get_request("#{container_url_for(@username)}/?path=")
|
|
||||||
else
|
|
||||||
get_response = do_get_request("#{container_url_for(@username)}/?path=#{escape(directory)}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
get_response.body
|
get_response.body
|
||||||
|
Loading…
x
Reference in New Issue
Block a user