diff --git a/app/models/attachment.rb b/app/models/attachment.rb index d68a050c1..1e4f731e7 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -404,6 +404,11 @@ class Attachment < ActiveRecord::Base self.class.extension_in?(File.extname(filename), extensions) end + # returns either MD5 or SHA256 depending on the way self.digest was computed + def digest_type + digest.size < 64 ? "MD5" : "SHA256" if digest.present? + end + private # Physically deletes the file from the file system diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 50e7bd966..5c827c195 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -12,7 +12,7 @@ <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc') %> <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc') %> <%= sort_header_tag('downloads', :caption => l(:label_downloads_abbr), :default_order => 'desc') %> - MD5 + <%= l(:field_digest) %> @@ -31,7 +31,7 @@ <%= format_time(file.created_on) %> <%= number_to_human_size(file.filesize) %> <%= file.downloads %> - <%= file.digest %> + <%= file.digest_type %>: <%= file.digest %> <%= link_to(image_tag('delete.png'), attachment_path(file), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 8388d4216..5adcb8f8f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -373,6 +373,7 @@ en: field_updated_by: Updated by field_last_updated_by: Last updated by field_full_width_layout: Full width layout + field_digest: Checksum setting_app_title: Application title setting_app_subtitle: Application subtitle