From 911c0478ba7e7bed6f268445ad1ca3e56e212cb2 Mon Sep 17 00:00:00 2001
From: Jeroen Massar <jeroen@massar.ch>
Date: Wed, 2 Oct 2019 18:15:52 +0200
Subject: [PATCH] Fix initial non-existent/empty log issue

Fixes bug where on initial session there is no file, and thus no lines
are read and one thus gets a index out of bounds error as lines is empty...
---
 sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/log.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/log.py b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/log.py
index d66008d..edf66ed 100644
--- a/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/log.py
+++ b/sdcard/rootfs/root/pwnagotchi/scripts/pwnagotchi/log.py
@@ -160,6 +160,9 @@ class SessionParser(object):
                         break
             lines.reverse()
 
+        if len(lines) == 0:
+            lines.append("Initial Session");
+
         self.last_session = lines
         self.last_session_id = hashlib.md5(lines[0].encode()).hexdigest()
         self.last_saved_session_id = self._get_last_saved_session_id()