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

Code cleanup

Andreas Pfohla89f100d18bc
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query.rb
index 896de899d55..cda875bdb81 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/internal/propfind_query.rb
@@ -28,6 +28,8 @@
module Storages::Peripherals::StorageInteraction::Nextcloud::Internal
class PropfindQuery
+ UTIL = ::Storages::Peripherals::StorageInteraction::Nextcloud::Util
+
# Only for information purposes currently.
# Probably a bit later we could validate `#call` parameters.
#
@@ -82,17 +84,15 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Internal
end
end.to_xml
- response = ::Storages::Peripherals::StorageInteraction::Nextcloud::Util.http(@uri).propfind(
- ::Storages::Peripherals::StorageInteraction::Nextcloud::Util
- .join_uri_path(
- @uri,
- 'remote.php/dav/files',
- CGI.escapeURIComponent(@username),
- ::Storages::Peripherals::StorageInteraction::Nextcloud::Util.escape_path(path)
- ),
+ response = UTIL.http(@uri).propfind(
+ UTIL.join_uri_path(
+ @uri,
+ 'remote.php/dav/files',
+ CGI.escapeURIComponent(@username),
+ UTIL.escape_path(path)
+ ),
body,
- ::Storages::Peripherals::StorageInteraction::Nextcloud::Util
- .basic_auth_header(@username, @password).merge('Depth' => depth)
+ UTIL.basic_auth_header(@username, @password).merge('Depth' => depth)
)
case response
@@ -100,12 +100,9 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Internal
doc = Nokogiri::XML response.body
result = {}
doc.xpath('/d:multistatus/d:response').each do |resource_section|
- resource = CGI
- .unescape(resource_section.xpath("d:href").text.strip)
- .gsub!(
- ::Storages::Peripherals::StorageInteraction::Nextcloud::Util
- .join_uri_path(@uri.path, "/remote.php/dav/files/#{@username}/"), ""
- )
+ resource = CGI.unescape(resource_section.xpath("d:href").text.strip)
+ .gsub!(UTIL.join_uri_path(@uri.path, "/remote.php/dav/files/#{@username}/"), "")
+
result[resource] = {}
# In future it could be useful to respond not only with found, but not found props as well
@@ -114,19 +111,16 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Internal
result[resource][node.name.to_s] = node.text.strip
end
end
+
ServiceResult.success(result:)
when Net::HTTPMethodNotAllowed
- ::Storages::Peripherals::StorageInteraction::Nextcloud::Util
- .error(:not_allowed)
+ UTIL.error(:not_allowed)
when Net::HTTPUnauthorized
- ::Storages::Peripherals::StorageInteraction::Nextcloud::Util
- .error(:not_authorized)
+ UTIL.error(:not_authorized)
when Net::HTTPNotFound
- ::Storages::Peripherals::StorageInteraction::Nextcloud::Util
- .error(:not_found)
+ UTIL.error(:not_found)
else
- ::Storages::Peripherals::StorageInteraction::Nextcloud::Util
- .error(:error)
+ UTIL.error(:error)
end
end
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 c1c89bb960f..aeeca57f37c 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
@@ -59,24 +59,24 @@ module Projects::Copy
source_folder_name = source_project_storage.project_folder_path
destination_folder_name = destination_project_storage.project_folder_path
- result = Storages::Peripherals::StorageRequests
- .new(storage: source_project_storage.storage)
- .copy_template_folder_command
- .call(source_path: source_folder_name, destination_path: destination_folder_name)
- result.on_failure { |r| add_error!(source_folder_name, r.to_active_model_errors) }
+ Storages::Peripherals::StorageRequests
+ .new(storage: source_project_storage.storage)
+ .copy_template_folder_command
+ .call(source_path: source_folder_name, destination_path: destination_folder_name)
+ .on_failure { |r| add_error!(source_folder_name, r.to_active_model_errors) }
end
def update_project_folder_id(project_storage)
destination_folder_name = project_storage.project_folder_path
- result = Storages::Peripherals::StorageRequests
- .new(storage: project_storage.storage)
- .file_id_query
- .call(path: destination_folder_name)
- result.match(
- on_success: ->(file_id) { project_storage.update!(project_folder_id: file_id) },
- on_failure: ->(error) { add_error!(destination_folder_name, error.to_active_model_errors) }
- )
+ Storages::Peripherals::StorageRequests
+ .new(storage: project_storage.storage)
+ .file_id_query
+ .call(path: destination_folder_name)
+ .match(
+ on_success: ->(file_id) { project_storage.update!(project_folder_id: file_id) },
+ on_failure: ->(error) { add_error!(destination_folder_name, error.to_active_model_errors) }
+ )
end
end
end