[#45860] fixed location property for storage files

pull/11945/head
Eric Schubert 2 years ago
parent ac87e7ee64
commit e46236d86c
No known key found for this signature in database
GPG Key ID: 1D346C019BD4BAA2
  1. 8
      modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_query.rb
  2. 17
      modules/storages/spec/common/peripherals/storage_requests_spec.rb

@ -33,7 +33,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
@uri = base_uri
@token = token
@retry_proc = retry_proc
@base_path = "/remote.php/dav/files/#{token.origin_user_id}"
@base_path = File.join(@uri.path, "remote.php/dav/files", token.origin_user_id)
end
def query(parent)
@ -42,7 +42,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
result = @retry_proc.call(@token) do |token|
response = http.propfind(
request_path(parent),
"#{@base_path}#{requested_folder(parent)}",
requested_properties,
{
'Depth' => '1',
@ -58,10 +58,6 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
private
def request_path(folder)
File.join(@uri.path, @base_path, requested_folder(folder)).gsub(/\/+$/, '')
end
def requested_folder(folder)
return '' if folder.nil?

@ -277,6 +277,23 @@ describe Storages::Peripherals::StorageRequests, webmock: true do
assert_requested(:propfind, request_url)
end
end
describe 'with storage running on a sub path and with parent parameter' do
let(:url) { 'https://example.com/storage' }
let(:parent) { '/Photos/Birds' }
let(:request_url) { "#{url}/remote.php/dav/files/#{origin_user_id}#{parent}" }
it do
subject
.files_query(user:)
.match(
on_success: ->(query) { query.call(parent) },
on_failure: ->(error) { raise "Files query could not be created: #{error}" }
)
assert_requested(:propfind, request_url)
end
end
end
describe 'with not supported storage type selected' do

Loading…
Cancel
Save