libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [libcloud] gvengel opened a new pull request #1326: Fix hash validation with stream uploads
Date Fri, 26 Jul 2019 21:17:50 GMT
gvengel opened a new pull request #1326: Fix hash validation with stream uploads
URL: https://github.com/apache/libcloud/pull/1326
 
 
   ## Fix hash validation with stream uploads
   
   ### Description
   
   Bug fix for cloudfiles upload_object_via_stream() erroneously throwing a hash mismatch
when using a file handle as the iterator. Example:
   
   ```python
   from libcloud.storage.providers import get_driver
   from libcloud.storage.types import ObjectDoesNotExistError
   
   driver = get_driver('cloudfiles')
   driver = driver('user', 'key')
   container = driver.get_container(container_name='test')
   with open('/tmp/test.file', 'w') as fh:
       fh.write('test')
   with open('/tmp/test.file') as fh:
       driver.upload_object_via_stream(iterator=fh, container=container, object_name='test.file')
   ```
   
   This would result in the exception:
   
   ```
   libcloud.storage.types.ObjectHashMismatchError: <ObjectHashMismatchError in <libcloud.storage.drivers.cloudfiles.CloudFilesStorageDriver
object at 0x103f43d68>, value=MD5 hash checksum does not match (expected=d41d8cd98f00b204e9800998ecf8427e,
actual=098f6bcd4621d373cade4e832627b4f6), object = test.file>
   ```
   
   d41d8cd98f00b204e9800998ecf8427e is the hash for an empty file. The problem is the upload
happens before the hash is calculated and the file handle is read to the EOF. The fix is to
seek the file handle to the beginning before feeding it into the hash function.
   
   
   ### Status
   
   done, ready for review
   
   ### Checklist (tick everything that applies)
   
   - [x] [Code linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide)
(required, can be done after the PR checks)
   - [ ] Documentation
   - [ ] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
   - [ ] [ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes)
(required for bigger changes)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message