Skip to content

Commit

Permalink
fixed crash when end_message is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhbir-singh committed Aug 1, 2018
1 parent 8c1536e commit 6edcb7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/views/rsnapshot_backups/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
br

- alert_type = "alert-danger"
- alert_type = "alert-success" unless log[:end_message].index("completed successfully").blank?
- alert_type = "alert-success" unless log[:end_message].blank? or log[:end_message].index("completed successfully").blank?
- alert_type = "alert-warning" if log[:end_message].blank?

div class="alert #{alert_type} mt-2" role="alert"
Expand Down
6 changes: 5 additions & 1 deletion lib/rsnapshot_backups/rsnapshot_log_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
class RsnapshotLogUtil
class << self
def parse_datetime_string(string)
DateTime.parse(string).ctime
parsed = DateTime.parse(string).strftime('%a, %d %b %Y %H:%M:%S')
ago_duration = time_ago_in_words(parsed).capitalize
parsed + " (#{ago_duration} ago)"
end

def get_log_file_path
Expand All @@ -18,6 +20,8 @@ def get_sample_log_file_path

def parse_log_file
log_enteries = []
return log_enteries unless File.exists?(get_log_file_path)

File.open(get_log_file_path, "r").each do |line|
if line =~ /\[.*\] \/bin\/rsnapshot (daily|weekly|monthly): .*/

Expand Down

0 comments on commit 6edcb7d

Please sign in to comment.