Skip to content

Commit ea81b10

Browse files
committed
adding additional fields to Item
1 parent 73d14eb commit ea81b10

File tree

1 file changed

+35
-5
lines changed

1 file changed

+35
-5
lines changed

Diff for: lib/net/dav.rb

+35-5
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,41 @@ def find(path, options = {})
458458
end
459459
end
460460
path.sub!(/\/$/, '')
461-
doc./('.//x:response', namespaces).each do |item|
462-
uri = @uri.merge(item.xpath("x:href", namespaces).inner_text)
463-
size = item.%(".//x:getcontentlength", namespaces).inner_text rescue nil
464-
type = item.%(".//x:collection", namespaces) ? :directory : :file
465-
res = Item.new(self, uri, type, size)
461+
462+
doc.root.children.each do |node|
463+
if node.name == 'response'
464+
uri = size = type = displayname = creationdate = lastmodified = ishidden = contenttype = nil
465+
node.children.each do |n|
466+
if n.name == 'href'
467+
uri = @uri.merge(n.inner_text)
468+
elsif n.name == 'propstat'
469+
n.children.each do |p1|
470+
if p1.name == 'prop'
471+
p1.children.each do |prop|
472+
case prop.name
473+
when 'getcontentlength'
474+
size = prop.inner_text
475+
when 'getncontenttype'
476+
contenttype = prop.inner_text
477+
when 'iscollection'
478+
type = (prop.inner_text.to_i == 1 ? :directory : :file)
479+
when 'displayname'
480+
displayname = prop.inner_text
481+
when 'creationdate'
482+
creationdate = prop.inner_text
483+
when 'getlastmodified'
484+
lastmodified = prop.inner_text
485+
when 'ishidden'
486+
ishidden = (prop.inner_text.to_i == 1 ? true : false)
487+
end
488+
end
489+
end
490+
end
491+
end
492+
end
493+
494+
res = Item.new(self, uri, type, size, displayname, creationdate, lastmodified, ishidden, contenttype)
495+
466496
if type == :file then
467497

468498
if(options[:filename])then

0 commit comments

Comments
 (0)