From aae77b2c370a366fd11ca36f55a915af511bdb5a Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 3 Jun 2015 10:50:02 +0100 Subject: Ensure that we don't use null variables. If we're sorting an empty array then return that empty array and save the pain of working with undefined time.attributes, & etc. --- lib/byteback/backup_directory.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/byteback/backup_directory.rb b/lib/byteback/backup_directory.rb index bdfc29c..f485297 100644 --- a/lib/byteback/backup_directory.rb +++ b/lib/byteback/backup_directory.rb @@ -11,6 +11,8 @@ module Byteback BACKUP_IMPORTANCE = [1, 2, 7, 14, 21, 28, 56, 112] def sort_by_importance(snapshots_unsorted, now=Time.now) + return snapshots_unsorted if ( snapshots_unsorted.size < 1 ) + # # Keep the last 7 days backups # -- cgit v1.2.3