diff --git a/app/models/s3_file.rb b/app/models/s3_file.rb
index 3a119b44..a75822b7 100644
--- a/app/models/s3_file.rb
+++ b/app/models/s3_file.rb
@@ -3,7 +3,7 @@ class S3File
include Rails.application.routes.url_helpers
include ActionView::Helpers::NumberHelper
- attr_accessor :safe_id, :filename, :last_modified, :size, :checksum, :url, :filename_display, :last_modified_display, :display_size
+ attr_accessor :safe_id, :filename, :last_modified, :size, :checksum, :url, :filename_display, :last_modified_display, :display_size, :is_folder
alias key filename
alias id filename
@@ -29,6 +29,7 @@ def initialize(filename:, last_modified:, size:, checksum:, work:, filename_disp
@checksum = checksum.delete('"')
@url = url || work_download_path(work, filename:)
@work = work
+ @is_folder = filename.ends_with?("/")
end
def created_at
diff --git a/app/models/work.rb b/app/models/work.rb
index e8fbd079..13b0436c 100644
--- a/app/models/work.rb
+++ b/app/models/work.rb
@@ -322,7 +322,8 @@ def file_list
"last_modified_display": s3_file.last_modified_display,
"size": s3_file.size,
"display_size": s3_file.display_size,
- "url": s3_file.url
+ "url": s3_file.url,
+ "is_folder": s3_file.is_folder
}
end
files_info
diff --git a/app/services/s3_query_service.rb b/app/services/s3_query_service.rb
index 029cbc65..96698bd3 100644
--- a/app/services/s3_query_service.rb
+++ b/app/services/s3_query_service.rb
@@ -211,6 +211,7 @@ def publish_files(current_user)
source_bucket = S3QueryService.pre_curation_config[:bucket]
target_bucket = S3QueryService.post_curation_config[:bucket]
empty_files = client_s3_empty_files(reload: true, bucket_name: source_bucket)
+ # See TODO below
# Do not move the empty files, however, ensure that it is noted that the
# presence of empty files is specified in the provenance log.
unless empty_files.empty?
@@ -368,7 +369,8 @@ def parse_objects(resp, ignore_directories: true)
resp_hash = resp.to_h
response_objects = resp_hash[:contents]
response_objects&.each do |object|
- next if object[:size] == 0 && ignore_directories
+ # TODO: Revisit this, we might need this logic
+ # next if object[:size] == 0 && ignore_directories
s3_file = S3File.new(work: model, filename: object[:key], last_modified: object[:last_modified], size: object[:size], checksum: object[:etag])
objects << s3_file
end
diff --git a/app/views/works/_s3_resources.html.erb b/app/views/works/_s3_resources.html.erb
index dbdacbd4..bcfff1e3 100644
--- a/app/views/works/_s3_resources.html.erb
+++ b/app/views/works/_s3_resources.html.erb
@@ -94,20 +94,28 @@
// On edit mode, file is marked to be deleted display strikethrough
html = `${row.filename_display.substring(1)}`;
} else {
- // Display as a hyperlink with the download icon
- // (Note: Interpolation in the client is interpreted after the server-side Ruby builds the download path)
- let downloadUrl;
- if (work) {
- downloadUrl = `<%= @work_decorator.download_path %>?filename=${data}`;
+ if (row.size == 0) {
+ // Display the filename as text (i.e. not a hyperlink)
+ html = `
+
+ ${row.filename_display}
+ `;
} else {
- downloadUrl = '<%= root_path %>';
- }
- var encodedUrl = window.encodeURI(downloadUrl);
+ // Display as a hyperlink with the download icon
+ // (Note: Interpolation in the client is interpreted after the server-side Ruby builds the download path)
+ let downloadUrl;
+ if (work) {
+ downloadUrl = `<%= @work_decorator.download_path %>?filename=${data}`;
+ } else {
+ downloadUrl = '<%= root_path %>';
+ }
+ var encodedUrl = window.encodeURI(downloadUrl);
- html = `
-
- ${row.filename_display}
- `;
+ html = `
+
+ ${row.filename_display}
+ `;
+ }
}
return html;
}
@@ -137,8 +145,13 @@
render: function (data, type, row) {
// size
if (type == "display") {
- // human readable (e.g. 34 KB)
- return row.display_size;
+ if (row.is_folder === true) {
+ // display no size for folders
+ return "";
+ } else {
+ // human readable (e.g. 34 KB)
+ return row.display_size;
+ }
}
// raw bytes
return row.size;