Commit d1ffbdfcb63bbd50573cfda4c59217bb60e76c7e
1 parent
bd83991a
Exists in
master
and in
4 other branches
Avoid 500 error on project page when application is close to RAM limit
Showing
2 changed files
with
10 additions
and
1 deletions
Show diff stats
app/helpers/projects_helper.rb
@@ -131,4 +131,13 @@ module ProjectsHelper | @@ -131,4 +131,13 @@ module ProjectsHelper | ||
131 | "your@email.com" | 131 | "your@email.com" |
132 | end | 132 | end |
133 | end | 133 | end |
134 | + | ||
135 | + def repository_size | ||
136 | + "#{@project.repository.size} MB" | ||
137 | + rescue | ||
138 | + # In order to prevent 500 error | ||
139 | + # when application cannot allocate memory | ||
140 | + # to calculate repo size - just show 'Unknown' | ||
141 | + 'unknown' | ||
142 | + end | ||
134 | end | 143 | end |
app/views/projects/show.html.haml
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | %p | 17 | %p |
18 | %p | 18 | %p |
19 | %span.light Repo size is | 19 | %span.light Repo size is |
20 | - #{@project.repository.size} MB | 20 | + = repository_size |
21 | %p | 21 | %p |
22 | %span.light Created at | 22 | %span.light Created at |
23 | #{@project.created_at.stamp('Aug 22, 2013')} | 23 | #{@project.created_at.stamp('Aug 22, 2013')} |