diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb index c68074a23f65..1bf71362f34f 100644 --- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb +++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb @@ -35,8 +35,8 @@ module OneDrive class CreateFolderCommand using ServiceResultRefinements - def self.call(storage:, folder_path:, parent_location: nil) - new(storage).call(folder_path:, parent_location:) + def self.call(storage:, folder_path:) + new(storage).call(folder_path:) end def initialize(storage) diff --git a/modules/storages/app/models/storages/project_storage.rb b/modules/storages/app/models/storages/project_storage.rb index f30619398fcb..36cbba198214 100644 --- a/modules/storages/app/models/storages/project_storage.rb +++ b/modules/storages/app/models/storages/project_storage.rb @@ -60,7 +60,7 @@ def automatic_management_possible? storage.present? && storage.automatic_management_enabled? end - def project_folder_path + def managed_project_folder_path case storage.short_provider_type when 'nextcloud' "#{storage.group_folder}/#{project.name.tr('/', '|')} (#{project.id})/" @@ -74,7 +74,7 @@ def project_folder_path def project_folder_location case storage.short_provider_type when 'nextcloud' - project_folder_path + managed_project_folder_path when 'one_drive' project_folder_id else @@ -83,7 +83,7 @@ def project_folder_location end def project_folder_path_escaped - escape_path(project_folder_path) + escape_path(managed_project_folder_path) end def file_inside_project_folder?(escaped_file_path) diff --git a/modules/storages/app/services/projects/copy/file_links_dependent_service.rb b/modules/storages/app/services/projects/copy/file_links_dependent_service.rb index 4c7ab9c4f757..905a46447037 100644 --- a/modules/storages/app/services/projects/copy/file_links_dependent_service.rb +++ b/modules/storages/app/services/projects/copy/file_links_dependent_service.rb @@ -64,7 +64,7 @@ def copy_dependency(*) file_ids: source_file_links.map(&:origin_id)) folder_files_file_ids_deep_query_result = folder_files_file_ids_deep_query( storage:, - path: target_project_storage.project_folder_path + path: target_project_storage.managed_project_folder_path ) source_file_links.each do |old_file_link| attributes = { diff --git a/modules/storages/app/services/projects/copy/storage_project_folders_dependent_service.rb b/modules/storages/app/services/projects/copy/storage_project_folders_dependent_service.rb index 4a44cbc7df6b..40a46fc7f058 100644 --- a/modules/storages/app/services/projects/copy/storage_project_folders_dependent_service.rb +++ b/modules/storages/app/services/projects/copy/storage_project_folders_dependent_service.rb @@ -63,7 +63,7 @@ def copy_dependency(*) def copy_project_folder(source_project_storage, destination_project_storage) source_folder_name = source_project_storage.project_folder_location - destination_folder_name = destination_project_storage.project_folder_path + destination_folder_name = destination_project_storage.managed_project_folder_path Storages::Peripherals::Registry .resolve("commands.#{source_project_storage.storage.short_provider_type}.copy_template_folder") diff --git a/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb b/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb index fa100d522bd0..98be8042a76b 100644 --- a/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb +++ b/modules/storages/app/services/storages/nextcloud_group_folder_properties_sync_service.rb @@ -132,7 +132,7 @@ def set_folders_permissions(remote_admins, project_storage) end command_params = { - path: project_storage.project_folder_path, + path: project_storage.managed_project_folder_path, permissions: { users: admin_permissions.to_h.merge(users_permissions), groups: { "#{@storage.group}": NO_PERMISSIONS } @@ -143,7 +143,7 @@ def set_folders_permissions(remote_admins, project_storage) .resolve("commands.nextcloud.set_permissions") .call(storage: @storage, **command_params) .result_or do |error| - format_and_log_error(error, folder: project_storage.project_folder_path) + format_and_log_error(error, folder: project_storage.managed_project_folder_path) end end @@ -186,11 +186,11 @@ def ensure_folders_exist(remote_folders) next create_folder(project_storage) unless id_folder_map.key?(project_storage.project_folder_id) current_path = id_folder_map[project_storage.project_folder_id] - if current_path != project_storage.project_folder_path + if current_path != project_storage.managed_project_folder_path rename_folder(project_storage, current_path).on_failure do |service_result| format_and_log_error(service_result.errors, source: current_path, - target: project_storage.project_folder_path) + target: project_storage.managed_project_folder_path) # we need to stop as this would mess with the other processes return service_result @@ -205,11 +205,11 @@ def ensure_folders_exist(remote_folders) def rename_folder(project_storage, current_name) Peripherals::Registry .resolve("commands.nextcloud.rename_file") - .call(storage: @storage, source: current_name, target: project_storage.project_folder_path) + .call(storage: @storage, source: current_name, target: project_storage.managed_project_folder_path) end def create_folder(project_storage) - folder_path = project_storage.project_folder_path + folder_path = project_storage.managed_project_folder_path Peripherals::Registry .resolve("commands.nextcloud.create_folder") .call(storage: @storage, folder_path:) diff --git a/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb b/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb index dc628f47759b..79bb8fab59d3 100644 --- a/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb +++ b/modules/storages/app/services/storages/one_drive_managed_folder_sync_service.rb @@ -70,8 +70,8 @@ def ensure_folders_exist(folder_map) active_project_storages_scope.includes(:project).find_each do |project_storage| next create_folder(project_storage) unless folder_map.key?(project_storage.project_folder_id) - if folder_map[project_storage.project_folder_id] != project_storage.project_folder_path - rename_folder(project_storage.project_folder_id, project_storage.project_folder_path) + if folder_map[project_storage.project_folder_id] != project_storage.managed_project_folder_path + rename_folder(project_storage.project_folder_id, project_storage.managed_project_folder_path) end end @@ -117,8 +117,8 @@ def rename_folder(source, target) def create_folder(project_storage) Peripherals::Registry .resolve('commands.one_drive.create_folder') - .call(storage: @storage, folder_path: project_storage.project_folder_path) - .match(on_failure: ->(error) { format_and_log_error(error, folder_path: project_storage.project_folder_path) }, + .call(storage: @storage, folder_path: project_storage.managed_project_folder_path) + .match(on_failure: ->(error) { format_and_log_error(error, folder_path: project_storage.managed_project_folder_path) }, on_success: ->(folder_info) do last_project_folder = ::Storages::LastProjectFolder .find_by( diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/copy_template_folder_command_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/copy_template_folder_command_spec.rb index 9a89506fd062..b080d5c90f64 100644 --- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/copy_template_folder_command_spec.rb +++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/copy_template_folder_command_spec.rb @@ -149,14 +149,11 @@ def create_base_folder def setup_template_folder raise if source_path.nil? - Storages::Peripherals::Registry - .resolve('commands.one_drive.create_folder') - .call(storage:, folder_path: 'Empty Subfolder', parent_location: source_path) - - subfolder = Storages::Peripherals::Registry - .resolve('commands.one_drive.create_folder') - .call(storage:, folder_path: 'Subfolder with File', parent_location: source_path).result + command = Storages::Peripherals::Registry + .resolve('commands.one_drive.create_folder').new(storage) + command.call(folder_path: 'Empty Subfolder', parent_location: source_path) + subfolder = command.call(folder_path: 'Subfolder with File', parent_location: source_path).result file_name = 'files_query_root.yml' token = OAuthClientToken.last diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/create_folder_command_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/create_folder_command_spec.rb index 28effbbe84f3..0894dd30f3d7 100644 --- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/create_folder_command_spec.rb +++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/create_folder_command_spec.rb @@ -48,7 +48,7 @@ expect(described_class).to respond_to(:call) method = described_class.method(:call) - expect(method.parameters).to contain_exactly(%i[keyreq storage], %i[keyreq folder_path], %i[key parent_location]) + expect(method.parameters).to contain_exactly(%i[keyreq storage], %i[keyreq folder_path]) end it 'is registered as create_folder' do @@ -67,7 +67,7 @@ it 'creates a sub folder', vcr: 'one_drive/create_folder_sub_folder' do folder = described_class.call(storage:, folder_path:).result - sub_folder = described_class.call(storage:, folder_path: "Another Folder", parent_location: folder.id).result + sub_folder = described_class.new(storage).call(folder_path: "Another Folder", parent_location: folder.id).result expect(sub_folder.name).to eq("Another Folder") expect(sub_folder.location).to eq("/#{folder_path}/Another Folder") diff --git a/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb b/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb index c5000e2e3314..b5747553eb86 100644 --- a/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb +++ b/modules/storages/spec/features/delete_project_storage_and_file_links_spec.rb @@ -49,7 +49,7 @@ let(:file_link) { create(:file_link, storage:, container: work_package) } let(:second_file_link) { create(:file_link, container: work_package, storage:) } let(:delete_folder_url) do - "#{storage.host}/remote.php/dav/files/#{storage.username}/#{project_storage.project_folder_path.chop}/" + "#{storage.host}/remote.php/dav/files/#{storage.username}/#{project_storage.managed_project_folder_path.chop}/" end before do diff --git a/modules/storages/spec/requests/api/v3/storages/storages_api_spec.rb b/modules/storages/spec/requests/api/v3/storages/storages_api_spec.rb index 99580dcc5d9d..cee81f76ec39 100644 --- a/modules/storages/spec/requests/api/v3/storages/storages_api_spec.rb +++ b/modules/storages/spec/requests/api/v3/storages/storages_api_spec.rb @@ -361,7 +361,7 @@ describe 'DELETE /api/v3/storages/:storage_id' do let(:path) { api_v3_paths.storage(storage.id) } let(:delete_folder_url) do - "#{storage.host}/remote.php/dav/files/#{storage.username}/#{project_storage.project_folder_path.chop}/" + "#{storage.host}/remote.php/dav/files/#{storage.username}/#{project_storage.managed_project_folder_path.chop}/" end let(:deletion_request_stub) do stub_request(:delete, delete_folder_url).to_return(status: 204, body: nil, headers: {}) diff --git a/modules/storages/spec/services/storages/nextcloud_group_folder_properties_sync_service_spec.rb b/modules/storages/spec/services/storages/nextcloud_group_folder_properties_sync_service_spec.rb index 3e572e6e9927..a61675ce848b 100644 --- a/modules/storages/spec/services/storages/nextcloud_group_folder_properties_sync_service_spec.rb +++ b/modules/storages/spec/services/storages/nextcloud_group_folder_properties_sync_service_spec.rb @@ -802,7 +802,7 @@ expect(OpenProject.logger) .to have_received(:warn) .with(source: "OpenProject/Lost Jedi Project Folder #3/", - target: project_storage2.project_folder_path, + target: project_storage2.managed_project_folder_path, command: Storages::Peripherals::StorageInteraction::Nextcloud::RenameFileCommand, message: 'Outbound request destination not found', data: { status: 404, body: '' }) diff --git a/modules/storages/spec/services/storages/one_drive_managed_folder_sync_service_spec.rb b/modules/storages/spec/services/storages/one_drive_managed_folder_sync_service_spec.rb index 6e965fd77a17..6a29e6c6183f 100644 --- a/modules/storages/spec/services/storages/one_drive_managed_folder_sync_service_spec.rb +++ b/modules/storages/spec/services/storages/one_drive_managed_folder_sync_service_spec.rb @@ -358,7 +358,7 @@ def project_folder_info(project_storage) end def create_folder_for(project_storage, folder_override = nil) - folder_path = folder_override || project_storage.project_folder_path + folder_path = folder_override || project_storage.managed_project_folder_path Storages::Peripherals::Registry.resolve('commands.one_drive.create_folder') .call(storage: project_storage.storage, folder_path:) diff --git a/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb b/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb index 7ba688799f56..bbd2f192a260 100644 --- a/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb +++ b/modules/storages/spec/services/storages/project_storages/delete_service_spec.rb @@ -132,7 +132,7 @@ let(:factory) { :project_storage } let(:host) { model_instance.storage.host } let(:username) { model_instance.storage.username } - let(:path) { model_instance.project_folder_path.chop } + let(:path) { model_instance.managed_project_folder_path.chop } let(:delete_folder_url) do "#{host}/remote.php/dav/files/#{username}/#{path}/" end diff --git a/spec/services/projects/delete_service_spec.rb b/spec/services/projects/delete_service_spec.rb index 148a9f00d4f6..12077a2d89e1 100644 --- a/spec/services/projects/delete_service_spec.rb +++ b/spec/services/projects/delete_service_spec.rb @@ -55,7 +55,7 @@ work_package = create(:work_package, project:) create(:file_link, container: work_package, storage:) delete_folder_url = - "#{storage.host}/remote.php/dav/files/#{storage.username}/#{project_storage.project_folder_path.chop}/" + "#{storage.host}/remote.php/dav/files/#{storage.username}/#{project_storage.managed_project_folder_path.chop}/" stub_request(:delete, delete_folder_url).to_return(status: 204, body: nil, headers: {})