From 260d023b65e4bff11a25fd8ab1e51dcb7a7e9b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 20 Jan 2016 15:42:24 +0100 Subject: [PATCH] FIX: disk_space should be a BigDecimal to handle large disk (closes #3923) --- lib/disk_space.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/disk_space.rb b/lib/disk_space.rb index 18f4d1a9fa6..69f541c3730 100644 --- a/lib/disk_space.rb +++ b/lib/disk_space.rb @@ -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