From notifications-return-15916-archive-asf-public=cust-asf.ponee.io@libcloud.apache.org Fri Jul 26 21:17:56 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 5C36A180595 for ; Fri, 26 Jul 2019 23:17:56 +0200 (CEST) Received: (qmail 80331 invoked by uid 500); 26 Jul 2019 21:17:55 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 80318 invoked by uid 99); 26 Jul 2019 21:17:55 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jul 2019 21:17:55 +0000 From: GitBox To: notifications@libcloud.apache.org Subject: [GitHub] [libcloud] gvengel opened a new pull request #1326: Fix hash validation with stream uploads Message-ID: <156417587059.32086.9765773875075706050.gitbox@gitbox.apache.org> Date: Fri, 26 Jul 2019 21:17:50 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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: , 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