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

Incorporates @Kharonus feedback

Marcello Rocha5d82e8aa2762
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/file_info_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/file_info_query.rb
index b12772c1d24..7861b45a913 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/file_info_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/file_info_query.rb
@@ -54,13 +54,13 @@ module Storages
)
end
- user_bound_result = Authentication[auth_strategy].call(storage: @storage) do |http|
+ requested_result = Authentication[auth_strategy].call(storage: @storage) do |http|
@drive_item_query.call(http:, drive_item_id: file_id, fields: FIELDS)
end
- user_bound_result.on_success { |sr| return ServiceResult.success(result: storage_file_infos(sr.result)) }
- user_bound_result.on_failure do |sr|
- return sr unless sr.result == :not_found
+ requested_result.on_success { |sr| return ServiceResult.success(result: storage_file_infos(sr.result)) }
+ requested_result.on_failure do |sr|
+ return sr unless sr.result == :not_found && auth_strategy.user.present?
return admin_query(file_id)
end
@@ -83,7 +83,7 @@ module Storages
def userless_strategy = Registry.resolve("one_drive.authentication.userless").call
def storage_file_infos(json, status: "ok", status_code: 200)
- info = StorageFileInfo.new(
+ StorageFileInfo.new(
status:,
status_code:,
id: json[:id],
@@ -94,14 +94,7 @@ module Storages
owner_id: json.dig(:createdBy, :user, :id),
trashed: false,
permissions: nil,
- location: Util.extract_location(json[:parentReference], json[:name])
- )
-
- add_file_change_info(info, json)
- end
-
- def add_file_change_info(file_info, json)
- file_info.with(
+ location: Util.extract_location(json[:parentReference], json[:name]),
last_modified_at: Time.zone.parse(json.dig(:fileSystemInfo, :lastModifiedDateTime)),
created_at: Time.zone.parse(json.dig(:fileSystemInfo, :createdDateTime)),
last_modified_by_name: json.dig(:lastModifiedBy, :user, :displayName),
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_info_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_info_query.rb
index 2cd9ec69feb..a28c51027e2 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_info_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_info_query.rb
@@ -44,6 +44,13 @@ module Storages
end
def call(auth_strategy:, file_ids:)
+ if file_ids.nil?
+ return ServiceResult.failure(
+ result: :error,
+ errors: ::Storages::StorageError.new(code: :error, log_message: "File IDs can not be nil")
+ )
+ end
+
result = Array(file_ids).map do |file_id|
file_info_result = FileInfoQuery.call(storage: @storage, auth_strategy:, file_id:)
diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_info_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_info_query_spec.rb
index 96b450749c6..6d1bc9802e0 100644
--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_info_query_spec.rb
+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_info_query_spec.rb
@@ -61,11 +61,11 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesInfoQue
end
context "with nil" do
- it "returns an empty array" do
+ it "returns an error" do
result = query.call(auth_strategy:, file_ids: nil)
- expect(result).to be_success
- expect(result.result).to eq([])
+ expect(result).to be_failure
+ expect(result.result).to eq(:error)
end
end
end