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

Refactored StorageFileInfo to be a Data.define

Andreas Pfohle8e887096cf7
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_info_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_info_query.rb
index 79364940d54..c28e35d14b4 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_info_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/files_info_query.rb
@@ -102,39 +102,27 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
result: response_object.ocs.data.to_h.map do |key, value|
if value.statuscode == 200
::Storages::StorageFileInfo.new(
- value.status,
- value.statuscode,
- value.id,
- value.name,
- Time.zone.at(value.mtime),
- Time.zone.at(value.ctime),
- value.mimetype,
- value.size,
- value.owner_name,
- value.owner_id,
- value.trashed,
- value.modifier_name,
- value.modifier_id,
- value.dav_permissions,
- location(value.path)
+ status: value.status,
+ status_code: value.statuscode,
+ id: value.id,
+ name: value.name,
+ last_modified_at: Time.zone.at(value.mtime),
+ created_at: Time.zone.at(value.ctime),
+ mime_type: value.mimetype,
+ size: value.size,
+ owner_name: value.owner_name,
+ owner_id: value.owner_id,
+ trashed: value.trashed,
+ last_modified_by_name: value.modifier_name,
+ last_modified_by_id: value.modifier_id,
+ permissions: value.dav_permissions,
+ location: location(value.path)
)
else
::Storages::StorageFileInfo.new(
- value.status,
- value.statuscode,
- key.to_s.to_i,
- nil,
- nil,
- nil,
- nil,
- nil,
- nil,
- nil,
- nil,
- nil,
- nil,
- nil,
- nil
+ status: value.status,
+ status_code: value.statuscode,
+ id: key.to_s.to_i
)
end
end
diff --git a/modules/storages/app/models/storages/storage_file_info.rb b/modules/storages/app/models/storages/storage_file_info.rb
index fb56d7fd170..4bece7e87b9 100644
--- a/modules/storages/app/models/storages/storage_file_info.rb
+++ b/modules/storages/app/models/storages/storage_file_info.rb
@@ -26,26 +26,82 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-class Storages::StorageFileInfo
- attr_reader :status, :status_code, :id, :name, :last_modified_at, :created_at, :mime_type, :size, :owner_name,
- :owner_id, :trashed, :last_modified_by_name, :last_modified_by_id, :permissions, :location
-
- def initialize(status, status_code, id, name, last_modified_at, created_at, mime_type, size, owner_name, owner_id,
- trashed, last_modified_by_name, last_modified_by_id, permissions, location)
- @status = status
- @status_code = status_code
- @id = id
- @name = name
- @last_modified_at = last_modified_at
- @created_at = created_at
- @mime_type = mime_type
- @size = size
- @owner_name = owner_name
- @owner_id = owner_id
- @trashed = trashed
- @last_modified_by_name = last_modified_by_name
- @last_modified_by_id = last_modified_by_id
- @permissions = permissions
- @location = location
+module Storages
+ StorageFileInfo = Data.define(
+ :status,
+ :status_code,
+ :id,
+ :name,
+ :last_modified_at,
+ :created_at,
+ :mime_type,
+ :size,
+ :owner_name,
+ :owner_id,
+ :trashed,
+ :last_modified_by_name,
+ :last_modified_by_id,
+ :permissions,
+ :location
+ ) do
+ def initialize(
+ status:,
+ status_code:,
+ id:,
+ name: nil,
+ last_modified_at: nil,
+ created_at: nil,
+ mime_type: nil,
+ size: nil,
+ owner_name: nil,
+ owner_id: nil,
+ trashed: nil,
+ last_modified_by_name: nil,
+ last_modified_by_id: nil,
+ permissions: nil,
+ location: nil
+ )
+ super(
+ status:,
+ status_code:,
+ id:,
+ name:,
+ last_modified_at:,
+ created_at:,
+ mime_type:,
+ size:,
+ owner_name:,
+ owner_id:,
+ trashed:,
+ last_modified_by_name:,
+ last_modified_by_id:,
+ permissions:,
+ location:
+ )
+ end
end
end
+
+# class Storages::StorageFileInfo
+# attr_reader :status, :status_code, :id, :name, :last_modified_at, :created_at, :mime_type, :size, :owner_name,
+# :owner_id, :trashed, :last_modified_by_name, :last_modified_by_id, :permissions, :location
+#
+# def initialize(status, status_code, id, name, last_modified_at, created_at, mime_type, size, owner_name, owner_id,
+# trashed, last_modified_by_name, last_modified_by_id, permissions, location)
+# @status = status
+# @status_code = status_code
+# @id = id
+# @name = name
+# @last_modified_at = last_modified_at
+# @created_at = created_at
+# @mime_type = mime_type
+# @size = size
+# @owner_name = owner_name
+# @owner_id = owner_id
+# @trashed = trashed
+# @last_modified_by_name = last_modified_by_name
+# @last_modified_by_id = last_modified_by_id
+# @permissions = permissions
+# @location = location
+# end
+# end