From d1ffbdfcb63bbd50573cfda4c59217bb60e76c7e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Date: Thu, 10 Oct 2013 11:05:49 +0300 Subject: [PATCH] Avoid 500 error on project page when application is close to RAM limit --- app/helpers/projects_helper.rb | 9 +++++++++ app/views/projects/show.html.haml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 17596b69c7d..d4f1a8f741f 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -131,4 +131,13 @@ module ProjectsHelper "your@email.com" end end + + def repository_size + "#{@project.repository.size} MB" + rescue + # In order to prevent 500 error + # when application cannot allocate memory + # to calculate repo size - just show 'Unknown' + 'unknown' + end end diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 06ca5169dff..aefcd833952 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -17,7 +17,7 @@ %p %p %span.light Repo size is - #{@project.repository.size} MB + = repository_size %p %span.light Created at #{@project.created_at.stamp('Aug 22, 2013')} -- 2.30.9