From 34123392f26cf00c158deb65ff37396e3341a71e Mon Sep 17 00:00:00 2001 From: Karel Picman Date: Fri, 4 Oct 2013 15:52:37 +0200 Subject: [PATCH] A file unlock exception handling --- app/controllers/dmsf_workflows_controller.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/dmsf_workflows_controller.rb b/app/controllers/dmsf_workflows_controller.rb index 5901158c..6f6f5ebf 100644 --- a/app/controllers/dmsf_workflows_controller.rb +++ b/app/controllers/dmsf_workflows_controller.rb @@ -48,7 +48,13 @@ class DmsfWorkflowsController < ApplicationController if revision if @workflow.try_finish revision, action, (params[:step_action].to_i / 10) file = DmsfFile.joins(:revisions).where(:dmsf_file_revisions => {:id => revision.id}).first - file.unlock! if file + if file + begin + file.unlock! + rescue DmsfLockError => e + logger.error e.message + end + end if revision.workflow == DmsfWorkflow::STATE_APPROVED # Just approved DmsfMailer.workflow_notification( @@ -107,8 +113,8 @@ class DmsfWorkflowsController < ApplicationController end end flash[:notice] = l(:notice_successful_update) - else - flash[:error] = l(:error_empty_note) + elsif action.action != DmsfWorkflowStepAction::ACTION_APPROVE && action.note.blank? + flash[:error] = l(:error_empty_note) end end end