From 33fd7fe4398a64dda63511b85f39da0632053e62 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Sat, 21 Sep 2024 01:55:25 -0700 Subject: [PATCH] fix log_list_view trying to seek past end of file on short logs --- archivebox/plugantic/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/archivebox/plugantic/views.py b/archivebox/plugantic/views.py index c0adc028..de14043b 100644 --- a/archivebox/plugantic/views.py +++ b/archivebox/plugantic/views.py @@ -399,7 +399,10 @@ def log_list_view(request: HttpRequest, **kwargs) -> TableContext: rows["Size"].append(f'{st.st_size//1000} kb') with open(logfile, 'rb') as f: - f.seek(-1024, os.SEEK_END) + try: + f.seek(-1024, os.SEEK_END) + except OSError: + f.seek(0) last_lines = f.read().decode().split("\n") non_empty_lines = [line for line in last_lines if line.strip()] rows["Most Recent Lines"].append(non_empty_lines[-1])