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

Makes the location match the Nextcloud implementation

Marcello Rocha54c8fa74e63d
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rb
index 0ed3a579778..f8633ec533f 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_query.rb
@@ -81,30 +81,32 @@ module Storages
end
def storage_files(json_files)
- files = json_files.map do |json|
- StorageFile.new(
- id: json[:id],
- name: json[:name],
- size: json[:size],
- mime_type: Util.mime_type(json),
- created_at: Time.zone.parse(json.dig(:fileSystemInfo, :createdDateTime)),
- last_modified_at: Time.zone.parse(json.dig(:fileSystemInfo, :lastModifiedDateTime)),
- created_by_name: json.dig(:createdBy, :user, :displayName),
- last_modified_by_name: json.dig(:lastModifiedBy, :user, :displayName),
- location: extract_location(json[:parentReference]),
- permissions: nil
- )
- end
+ files = json_files.map { |json| storage_file(json) }
parent_reference = json_files.first[:parentReference]
StorageFiles.new(files, parent(parent_reference), forge_ancestors(parent_reference))
end
- def extract_location(parent_reference)
+ def storage_file(json_file)
+ StorageFile.new(
+ id: json_file[:id],
+ name: json_file[:name],
+ size: json_file[:size],
+ mime_type: Util.mime_type(json_file),
+ created_at: Time.zone.parse(json_file.dig(:fileSystemInfo, :createdDateTime)),
+ last_modified_at: Time.zone.parse(json_file.dig(:fileSystemInfo, :lastModifiedDateTime)),
+ created_by_name: json_file.dig(:createdBy, :user, :displayName),
+ last_modified_by_name: json_file.dig(:lastModifiedBy, :user, :displayName),
+ location: extract_location(json_file[:parentReference], json_file[:name]),
+ permissions: nil
+ )
+ end
+
+ def extract_location(parent_reference, file_name = '')
location = parent_reference[:path].gsub(/.*root:/, '')
- location.empty? ? '/' : location
+ location.empty? ? "/#{file_name}" : "#{location}/#{file_name}"
end
def parent(parent_reference)
diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb
index 4e6d8346853..b14fb76b56b 100644
--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb
+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb
@@ -71,7 +71,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,
last_modified_at: Time.parse("2017-08-07T16:07:10Z"),
created_by_name: "Megan Bowen",
last_modified_by_name: "Megan Bowen",
- location: "/",
+ location: "/All Japan Revenues By City.xlsx",
permissions: nil })
end