mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-12 22:25:44 -04:00
fix log_list_view trying to seek past end of file on short logs
This commit is contained in:
parent
aa21c56ddd
commit
33fd7fe439
1 changed files with 4 additions and 1 deletions
|
@ -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:
|
||||
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])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue