parent
207bb0efde
commit
9dda344b26
@ -78,10 +78,16 @@ module RemoteStorage
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
res = do_get_request("#{container_url_for(user)}/?format=json&path=#{escape(directory)}/")
|
is_root_listing = directory.empty?
|
||||||
|
|
||||||
|
res = if is_root_listing
|
||||||
|
do_get_request("#{container_url_for(user)}/?format=json")
|
||||||
|
else
|
||||||
|
do_get_request("#{container_url_for(user)}/?format=json&path=#{escape(directory)}/")
|
||||||
|
end
|
||||||
|
|
||||||
if body = JSON.parse(res.body)
|
if body = JSON.parse(res.body)
|
||||||
listing = directory_listing(body)
|
listing = directory_listing(body, is_root_listing)
|
||||||
else
|
else
|
||||||
puts "listing not JSON"
|
puts "listing not JSON"
|
||||||
end
|
end
|
||||||
@ -169,14 +175,15 @@ module RemoteStorage
|
|||||||
permission
|
permission
|
||||||
end
|
end
|
||||||
|
|
||||||
def directory_listing(res_body)
|
def directory_listing(res_body, is_root_listing = false)
|
||||||
listing = {
|
listing = {
|
||||||
"@context" => "http://remotestorage.io/spec/folder-description",
|
"@context" => "http://remotestorage.io/spec/folder-description",
|
||||||
"items" => {}
|
"items" => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
res_body.each do |entry|
|
res_body.each do |entry|
|
||||||
name = entry["name"].gsub("#{File.dirname(entry["name"])}/", '')
|
name = entry["name"]
|
||||||
|
name.sub!("#{File.dirname(entry["name"])}/", '') unless is_root_listing
|
||||||
if name[-1] == "/"
|
if name[-1] == "/"
|
||||||
listing["items"].merge!({
|
listing["items"].merge!({
|
||||||
name => {
|
name => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user