basic_cmds/cat: do not check file size at all

This commit is contained in:
Oleksii Shevchuk 2019-08-19 21:52:37 +03:00
parent be9828f451
commit 3ea43e50f9
1 changed files with 4 additions and 13 deletions

View File

@ -644,19 +644,10 @@ def cat(path, N, n, grep, encoding=None, filter_out=False):
if n and len(data) >= n:
break
else:
try:
fin.seek(0, os.SEEK_END)
file_size = fin.tell()
fin.seek(0)
block_size = 4*8192
block = fin.read(block_size)
if file_size > block_size:
block += "\n[FILE TRUNCATED, USE DOWNLOAD]"
except IOError as e:
if e.errno != errno.EINVAL:
# File does not support seek
raise
block = fin.read()
block_size = 4*8192
block = fin.read(block_size)
if len(block) == block_size:
block += "\n[FILE TRUNCATED, USE DOWNLOAD]"
return block
else: