tahoe-lafs / zfec

zfec -- an efficient, portable erasure coding tool
Other
374 stars 44 forks source link

Reading from pipe results in Illegal seek #3

Closed iammer closed 6 years ago

iammer commented 7 years ago

This works: zfec - < some-file

However this: cat some-file | zfec - results in:

Traceback (most recent call last):
  File "/usr/local/bin/zfec", line 9, in <module>
    load_entry_point('zfec==1.4.23+23.g40c6727', 'console_scripts', 'zfec')()
  File "/usr/local/lib/python2.7/dist-packages/zfec-1.4.23+23.g40c6727-py2.7-linux-x86_64.egg/zfec/cmdline_zfec.py", line 60, in main
    args.inputfile.seek(0, 2)
IOError: [Errno 29] Illegal seek
mic159 commented 7 years ago

The first gives zfec the actual file object as its stdin, and thus can seek. The second command is a pipe, which is a stream that cannot be seeked.

Looks like the command line script requires the complete filesize upfront, which is why it tries to seek to the end.

warner commented 6 years ago

We should wrap that seek() in something which catches the IOError and wraps it in a better error message, something like "sorry, zfec - needs a real (Seekable) filehandle so it can measure the file size".