From 1249ecead709465ac035058fa749ebcf80a14bb5 Mon Sep 17 00:00:00 2001 From: Matthew Bloch Date: Thu, 20 Nov 2014 10:45:49 +0000 Subject: Added extra attributes to DiskFreeHistory (needed by byteback-prune). --- lib/byteback/disk_free_history.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/byteback/disk_free_history.rb b/lib/byteback/disk_free_history.rb index daa68bc..6be8143 100755 --- a/lib/byteback/disk_free_history.rb +++ b/lib/byteback/disk_free_history.rb @@ -20,6 +20,8 @@ module Byteback # point's disk space history. # class DiskFreeHistory + attr_reader :mountpoint, :history_file + MINIMUM_INTERVAL = 5*60 # don't take readings more than 5 mins apart MAXIMUM_AGE = 7*24*60*60 # delete readings after a week @@ -71,11 +73,13 @@ module Byteback value_from_reading.call(later_reading) total += difference end - break if reading.time < earliest readings += 1 + break if reading.time < earliest later_reading = reading end + return 0 if readings == 0 + total / readings end -- cgit v1.2.1