Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#45860] fixed location property for storage files

Eric Schuberte46236d86cfa
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_query.rb
index 7e1048db9e8..c469a66da32 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_query.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?
diff --git a/modules/storages/spec/common/peripherals/storage_requests_spec.rb b/modules/storages/spec/common/peripherals/storage_requests_spec.rb
index d7117e58848..45a7e9b3afc 100644
--- a/modules/storages/spec/common/peripherals/storage_requests_spec.rb
+++ b/modules/storages/spec/common/peripherals/storage_requests_spec.rb
@@ -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