Update _hash_buffered_stream methos so we ignore "illegal seek" error.
That error likely represents a file handler / iterator which doesn't
support a seek operation (such as pipe) and in such scenario we simply
want to ignore that error.
@@ -29,6 +29,7 @@ from typing import Type
import os.path # pylint: disable-msg=W0404
import hashlib
import warnings
+import errno
from os.path import join as pjoin
from libcloud.utils.py3 import httplib
@@ -738,7 +739,18 @@ class StorageDriver(BaseDriver):
# Ensure we start from the begining of a stream in case stream is
# not at the beginning
if hasattr(stream, 'seek'):
+ try:
stream.seek(0)
+ except OSError as e:
+ if e.errno != errno.ESPIPE:
+ # This error number represents OSError: [Errno 29]
+ # Illegal seek error.
+ # This could either mean that the underlying handle
+ # doesn't support seek operation (e.g. pipe) or that
+ # the invalid seek position is provided. Sadly there is
+ # no good robust way to distinghuish that so we simply ignore
+ # all the "Illeal seek errors"
+ raise e
for chunk in libcloud.utils.files.read_in_chunks(iterator=stream):
hasher.update(b(chunk))
