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

Adopts @akabiru feedback

Marcello Rocha72b6459aa4fb
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 19dd527df74..2336a953005 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
@@ -47,7 +47,7 @@ module Storages
remote_urls = build_origin_urls(**valid_input_result.result)
- remote_folder_does_not_exist?(remote_urls[:destination_url]).on_failure { |failure| return failure }
+ ensure_remote_folder_does_not_exist(remote_urls[:destination_url]).on_failure { |failure| return failure }
copy_folder(**remote_urls).on_failure { |failure| return failure }
@@ -87,7 +87,7 @@ module Storages
{ source_url:, destination_url: }
end
- def remote_folder_does_not_exist?(destination_url)
+ def ensure_remote_folder_does_not_exist(destination_url)
response = OpenProject.httpx.basic_auth(@storage.username, @storage.password).head(destination_url)
case response
diff --git a/modules/storages/app/services/storages/file_links/copy_file_links_service.rb b/modules/storages/app/services/storages/file_links/copy_file_links_service.rb
index a7b3cf33b87..4be3db694ce 100644
--- a/modules/storages/app/services/storages/file_links/copy_file_links_service.rb
+++ b/modules/storages/app/services/storages/file_links/copy_file_links_service.rb
@@ -45,8 +45,6 @@ module Storages
end
def call
- OpenProject.logger.error "STORAGE CLASS: #{@source.storage.class}, #{@target.storage.class}"
-
source_file_links = FileLink
.includes(:creator)
.where(storage: @source.storage,
@@ -54,7 +52,7 @@ module Storages
container_type: "WorkPackage")
with_locale_for(@user) do
- if @source.project_folder_mode == "automatic"
+ if @source.project_folder_automatic?
create_managed_file_links(source_file_links)
else
create_unmanaged_file_links(source_file_links)
@@ -101,11 +99,17 @@ module Storages
end
end
+ def auth_strategy
+ Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken
+ .strategy
+ .with_user(@user)
+ end
+
# Known issue, this can lead to 403s.
def source_files_info(source_file_links)
Peripherals::Registry
.resolve("#{@source.storage.short_provider_type}.queries.files_info")
- .call(storage: @source.storage, user: @user, file_ids: source_file_links.pluck(:origin_id))
+ .call(storage: @source.storage, auth_strategy:, file_ids: source_file_links.pluck(:origin_id))
end
def target_files_map
diff --git a/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb b/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb
index c2103396d99..5132c6491ba 100644
--- a/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb
+++ b/modules/storages/spec/workers/storages/copy_project_folders_job_spec.rb
@@ -128,7 +128,7 @@ RSpec.describe Storages::CopyProjectFoldersJob, :job, :webmock, with_good_job_ba
})
Storages::Peripherals::Registry
- .stub("#{storage.short_provider_type}.queries.files_info", ->(storage:, user:, file_ids:) {
+ .stub("#{storage.short_provider_type}.queries.files_info", ->(storage:, auth_strategy:, file_ids:) {
ServiceResult.success(result: source_file_infos)
})
@@ -182,7 +182,7 @@ RSpec.describe Storages::CopyProjectFoldersJob, :job, :webmock, with_good_job_ba
})
Storages::Peripherals::Registry
- .stub("#{storage.short_provider_type}.queries.files_info", ->(storage:, user:, file_ids:) {
+ .stub("#{storage.short_provider_type}.queries.files_info", ->(storage:, auth_strategy:, file_ids:) {
ServiceResult.success(result: source_file_infos)
})