Skip to content

Commit ce01db2

Browse files
committed
fix get_oldest_logfile with no log files'
1 parent 121a566 commit ce01db2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cosmos/lib/cosmos/api/tlm_api.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,14 @@ def get_oldest_logfile(scope: $cosmos_scope, token: $cosmos_token)
358358
# Request the path by calling the key method. Returns something like this:
359359
# DEFAULT/decom_logs/tlm/INST2/MECH/20220104/20220104165449021942700__20220104170449148642700__DEFAULT__INST2__MECH__rt__decom.bin
360360
# Thus we split and take the start date/time part of the filename
361-
start = list[0].key.split('/')[-1].split('__')[0]
362-
# Format as YYYY-MM-DD HH:MM:SS for use by the frontend
363-
# utc_time = Time.utc(start[0,4], start[4,2], start[6,2], start[8,2], start[10,2], start[12,2])
364-
return "#{start[0,4]}-#{start[4,2]}-#{start[6,2]} #{start[8,2]}:#{start[10,2]}:#{start[12,2]}"
361+
if list and list[0]
362+
start = list[0].key.split('/')[-1].split('__')[0]
363+
# Format as YYYY-MM-DD HH:MM:SS for use by the frontend
364+
# utc_time = Time.utc(start[0,4], start[4,2], start[6,2], start[8,2], start[10,2], start[12,2])
365+
return "#{start[0,4]}-#{start[4,2]}-#{start[6,2]} #{start[8,2]}:#{start[10,2]}:#{start[12,2]}"
366+
else
367+
return Time.now.utc.to_s[0..18]
368+
end
365369
end
366370

367371
# PRIVATE

0 commit comments

Comments
 (0)