Skip to content

Commit

Permalink
utils:functions - fix get_eof when file size is smaller than chunk size
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Nov 10, 2023
1 parent 2324d64 commit 7661ba9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion acacore/utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def get_eof(path: Path, chunk_size: int = 1024) -> bytes:
bytes: The contents of the last chunk of the file as a bytes object.
"""
with path.open("rb") as f:
f.seek(path.stat().st_size - chunk_size)
file_size: int = path.stat().st_size
f.seek(file_size if chunk_size > file_size else chunk_size)
return f.read(chunk_size)


Expand Down

0 comments on commit 7661ba9

Please sign in to comment.