diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 5347b144..45e70e15 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -185,7 +185,11 @@ class DmsfController < ApplicationController flash[:error] = l(:error_email_to_must_be_entered) else DmsfMailer.deliver_send_documents(@project, params[:email].permit!, User.current) - File.delete(params[:email][:zipped_content]) + if(File.exist?(params[:email][:zipped_content])) + File.delete(params[:email][:zipped_content]) + else + flash[:error] = l(:header_minimum_filesize) + end flash[:notice] = l(:notice_email_sent, params[:email][:to]) end redirect_to dmsf_folder_path(id: @project, folder_id: @folder) diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index 66438fb7..5e4b2657 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -84,8 +84,12 @@ class DmsfMailer < Mailer @files = email_params[:files] @author = author unless @links_only - zipped_content_data = open(email_params[:zipped_content], 'rb') { |io| io.read } - attachments['Documents.zip'] = { content_type: 'application/zip', content: zipped_content_data } + if File.exist?(email_params[:zipped_content]) + zipped_content_data = open(email_params[:zipped_content], 'rb') { |io| io.read } + attachments['Documents.zip'] = { content_type: 'application/zip', content: zipped_content_data } + else + Rails.logger.error "Cannot attach #{email_params[:zipped_content]}, it doesn't exist." + end end mail to: email_params[:to], cc: email_params[:cc], subject: email_params[:subject], 'From' => email_params[:from], 'Reply-To' => email_params[:reply_to] diff --git a/app/views/dmsf_context_menus/_file.html.erb b/app/views/dmsf_context_menus/_file.html.erb index e352f54b..f94169d8 100644 --- a/app/views/dmsf_context_menus/_file.html.erb +++ b/app/views/dmsf_context_menus/_file.html.erb @@ -28,11 +28,15 @@ <%= link_to "#{l(:button_copy)}/#{l(:button_move)}", copy_file_path(id: dmsf_file), title: l(:title_copy), class: 'icon icon-copy', disabled: !dmsf_link.nil? %> -<%= link_to l(:label_link_to), - new_dmsf_link_path(project_id: project.id, - dmsf_folder_id: dmsf_file.dmsf_folder ? dmsf_file.dmsf_folder.id : nil, - dmsf_file_id: dmsf_file.id, type: 'link_to'), - title: l(:title_create_link), class: 'icon icon-link' %> +<% unless dmsf_link %> +