mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 21:12:45 +08:00
FIX: disk_space should be a BigDecimal to handle large disk (closes #3923)
This commit is contained in:
parent
fc3bedaaed
commit
260d023b65
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user