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

[#59344] fix copy folder query to fetch correct id

Eric Schubert57d6a52e7193
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rb
index c69ef2e6d21..7b673626cf1 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/copy_template_folder_command.rb
@@ -137,10 +137,14 @@ module Storages
# rubocop:enable Metrics/AbcSize
def get_folder_id(auth_strategy, destination_path)
+ # file_path_to_id_map query returns keys without trailing slashes
+ # TODO: Harden this with https://community.openproject.org/wp/57850
+ sanitized_path = destination_path.chomp("/")
+
Registry
.resolve("nextcloud.queries.file_path_to_id_map")
- .call(storage: @storage, auth_strategy:, folder: ParentFolder.new(destination_path), depth: 0)
- .map { |result| @data.with(id: result[destination_path].id) }
+ .call(storage: @storage, auth_strategy:, folder: ParentFolder.new(sanitized_path), depth: 0)
+ .map { |result| @data.with(id: result[sanitized_path].id) }
end
def source = self.class