FIX: disk_space should be a BigDecimal to handle large disk (closes #3923)

This commit is contained in:
Régis Hanol 2016-01-20 15:42:24 +01:00
parent fc3bedaaed
commit 260d023b65

View File

@ -1,3 +1,5 @@
require "bigdecimal"
class DiskSpace
extend ActionView::Helpers::NumberHelper
@ -57,11 +59,13 @@ class DiskSpace
protected
def self.free(path)
`df -Pk #{path} | awk 'NR==2 {print $4 * 1024;}'`.to_i
number = `df -Pk #{path} | awk 'NR==2 {print $4 * 1024;}'`.strip
BigDecimal.new(number).to_i
end
def self.used(path)
`du -s #{path}`.to_i * 1024
number = `du -s #{path}`
BigDecimal.new(number).to_i * 1024
end
end