Use last instead of [-1]
This commit is contained in:
@@ -222,7 +222,7 @@ module Calligraphy
|
|||||||
def refresh_lock
|
def refresh_lock
|
||||||
if locked?
|
if locked?
|
||||||
@store.transaction do
|
@store.transaction do
|
||||||
@store[:lockdiscovery][-1][:timeout] = timeout_node
|
@store[:lockdiscovery].last[:timeout] = timeout_node
|
||||||
end
|
end
|
||||||
|
|
||||||
fetch_lock_info
|
fetch_lock_info
|
||||||
@@ -416,7 +416,8 @@ module Calligraphy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def lockscope
|
def lockscope
|
||||||
@lock_info[-1][:lockscope]
|
@lock_info
|
||||||
|
.last[:lockscope]
|
||||||
.children
|
.children
|
||||||
.select { |x| x.is_a? Nokogiri::XML::Element }
|
.select { |x| x.is_a? Nokogiri::XML::Element }
|
||||||
.last
|
.last
|
||||||
@@ -439,7 +440,7 @@ module Calligraphy
|
|||||||
|
|
||||||
def locking_ancestor?(ancestor_path, ancestors, headers = nil)
|
def locking_ancestor?(ancestor_path, ancestors, headers = nil)
|
||||||
ancestor_info = ancestor_lock_info headers
|
ancestor_info = ancestor_lock_info headers
|
||||||
ancestor_store_path = "#{ancestor_path}/#{ancestors[-1]}.pstore"
|
ancestor_store_path = "#{ancestor_path}/#{ancestors.last}.pstore"
|
||||||
|
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
|
|
||||||
@@ -669,7 +670,7 @@ module Calligraphy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def refresh_ancestor_locks(ancestor_path, ancestors)
|
def refresh_ancestor_locks(ancestor_path, ancestors)
|
||||||
ancestor_store_path = "#{ancestor_path}/#{ancestors[-1]}.pstore"
|
ancestor_store_path = "#{ancestor_path}/#{ancestors.last}.pstore"
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
|
|
||||||
if File.exist? ancestor_store_path
|
if File.exist? ancestor_store_path
|
||||||
@@ -686,7 +687,7 @@ module Calligraphy
|
|||||||
ancestor_store = PStore.new ancestor_store_path
|
ancestor_store = PStore.new ancestor_store_path
|
||||||
|
|
||||||
ancestor_store.transaction do
|
ancestor_store.transaction do
|
||||||
ancestor_store[:lockdiscovery][-1][:timeout] = timeout_node
|
ancestor_store[:lockdiscovery].last[:timeout] = timeout_node
|
||||||
ancestor_store[:lockdiscovery]&.map do |lock_info|
|
ancestor_store[:lockdiscovery]&.map do |lock_info|
|
||||||
lock_info.transform_values do |xml_fragment|
|
lock_info.transform_values do |xml_fragment|
|
||||||
parse_serialized_fragment xml_fragment
|
parse_serialized_fragment xml_fragment
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ module Calligraphy
|
|||||||
@full_request_path = req&.original_url
|
@full_request_path = req&.original_url
|
||||||
@mount_point = mount || req&.path&.tap { |s| s.slice! resource }
|
@mount_point = mount || req&.path&.tap { |s| s.slice! resource }
|
||||||
@request_body = req&.body&.read || ''
|
@request_body = req&.body&.read || ''
|
||||||
@request_path = mount.nil? ? resource : resource.split(mount)[-1]
|
@request_path = mount.nil? ? resource : resource.split(mount).last
|
||||||
@root_dir = root_dir
|
@root_dir = root_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ module Calligraphy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destination_header
|
def destination_header
|
||||||
@headers['Destination'].split(@headers['Host'])[-1]
|
@headers['Destination'].split(@headers['Host']).last
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_trailing_slash(input)
|
def remove_trailing_slash(input)
|
||||||
input[-1] == '/' ? input[0..-2] : input
|
input.last == '/' ? input[0..-2] : input
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ module Calligraphy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extract_lock_token(properties)
|
def extract_lock_token(properties)
|
||||||
properties[-1]
|
properties
|
||||||
|
.last
|
||||||
.select { |x| x.name == 'locktoken' }[0]
|
.select { |x| x.name == 'locktoken' }[0]
|
||||||
.children
|
.children
|
||||||
.text
|
.text
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ module Calligraphy
|
|||||||
|
|
||||||
# Executes the WebDAV request for a particular resource.
|
# Executes the WebDAV request for a particular resource.
|
||||||
def execute
|
def execute
|
||||||
|
# The `propfind` tag contains the properties to retrieve for a
|
||||||
|
# particular resource.
|
||||||
xml = xml_for body: body, node: 'propfind'
|
xml = xml_for body: body, node: 'propfind'
|
||||||
return :bad_request if xml == :bad_request
|
return :bad_request if xml == :bad_request
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ module Calligraphy
|
|||||||
xml_str = fragment.is_a?(Array) ? fragment.join : fragment
|
xml_str = fragment.is_a?(Array) ? fragment.join : fragment
|
||||||
|
|
||||||
xml = Nokogiri::XML.fragment(xml_str).children
|
xml = Nokogiri::XML.fragment(xml_str).children
|
||||||
fragment.is_a?(Array) ? xml : xml[-1]
|
fragment.is_a?(Array) ? xml : xml.last
|
||||||
end
|
end
|
||||||
|
|
||||||
# Iterates through each property in `properties` hash and deserializes
|
# Iterates through each property in `properties` hash and deserializes
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ module Calligraphy
|
|||||||
def lock_response(activelock_properties)
|
def lock_response(activelock_properties)
|
||||||
build :prop do |xml|
|
build :prop do |xml|
|
||||||
xml.lockdiscovery do
|
xml.lockdiscovery do
|
||||||
activelock_properties.each do |properties|
|
activelock_properties.each do |property_set|
|
||||||
xml.activelock do
|
xml.activelock do
|
||||||
iterate_and_drilldown xml, properties
|
iterate_and_drilldown xml, property_set
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user