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

Rename move_folder method and actually deal with errors moving forward.

Marcello Rocha0775cb45aa79
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
index b3502e58af6..2a7a612976e 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2023 the OpenProject GmbH
@@ -53,15 +55,15 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
.map(&:text)
ServiceResult.success(result: group_users)
when Net::HTTPMethodNotAllowed
- Util.error(:not_allowed)
- when Net::HTTPUnauthorized
- Util.error(:unauthorized)
+ Util.error(:not_allowed, 'Outbound request method not allowed', response)
when Net::HTTPNotFound
- Util.error(:not_found)
+ Util.error(:not_found, 'Outbound request destination not found', response)
+ when Net::HTTPUnauthorized
+ Util.error(:unauthorized, 'Outbound request not authorized', response)
when Net::HTTPConflict
- Util.error(:conflict, error_text_from_response(response))
+ Util.error(:conflict, Util.error_text_from_response(response), response)
else
- Util.error(:error)
+ Util.error(:error, 'Outbound request failed', response)
end
end
# rubocop:enable Metrics/AbcSize
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 7ae1aa25c37..9855eac583f 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
@@ -120,13 +120,13 @@ module Storages::Peripherals::StorageInteraction::Nextcloud::Internal
ServiceResult.success(result:)
when Net::HTTPMethodNotAllowed
- UTIL.error(:not_allowed)
- when Net::HTTPUnauthorized
- UTIL.error(:unauthorized)
+ UTIL.error(:not_allowed, 'Outbound request method not allowed', response)
when Net::HTTPNotFound
UTIL.error(:not_found, 'Outbound request destination not found', response)
+ when Net::HTTPUnauthorized
+ UTIL.error(:unauthorized, 'Outbound request not authorized', response)
else
- UTIL.error(:error, '', response)
+ UTIL.error(:error, 'Outbound request failed', response)
end
end
diff --git a/modules/storages/app/services/storages/group_folder_properties_sync_service.rb b/modules/storages/app/services/storages/group_folder_properties_sync_service.rb
index 3086b0a7e05..c305f0a9773 100644
--- a/modules/storages/app/services/storages/group_folder_properties_sync_service.rb
+++ b/modules/storages/app/services/storages/group_folder_properties_sync_service.rb
@@ -93,7 +93,13 @@ module Storages
end
def add_remove_users_to_group
- remote_users = remote_group_users.result_or { puts :error }
+ remote_users = remote_group_users.result_or do |error|
+ return OpenProject.logger.warn({ command: 'nextcloud.group_users',
+ group: @storage.group,
+ message: error.log_message,
+ data: { status: error.data.code, body: error.data.body } }.to_json)
+ end
+
local_users = client_tokens_scope.order(:id).pluck(:origin_user_id)
(remote_users - local_users - [@storage.username]).each do |user|
@@ -204,7 +210,7 @@ module Storages
if current_path == project_storage.project_folder_path
project_storage.project_folder_id
else
- move_folder(project_storage, current_path)
+ rename_folder(project_storage, current_path)
.result_or do |error|
error_msg = { command: 'nextcloud.rename_file',
source: current_path,
@@ -218,7 +224,7 @@ module Storages
end
end
- def move_folder(project_storage, current_name)
+ 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)
@@ -237,12 +243,17 @@ module Storages
return OpenProject.logger.warn(error_msg)
end
- folder_ids = Peripherals::Registry
- .resolve('queries.nextcloud.file_ids')
- .call(storage: @storage, path: folder_path)
- .result_or { |_error| puts :error } # Log this
+ folder_id = Peripherals::Registry
+ .resolve('queries.nextcloud.file_ids')
+ .call(storage: @storage, path: folder_path)
+ .result_or do |error|
+ return OpenProject.logger.warn({ command: 'nextcloud.file_ids',
+ path:,
+ message: error.log_message,
+ data: { status: error.data.code, body: error.data.body } }.to_json)
+ end
- project_storage.update(project_folder_id: folder_ids.dig(folder_path, 'fileid'))
+ project_storage.update(project_folder_id: folder_id.dig(folder_path, 'fileid'))
project_storage.reload.project_folder_id
end