From 9979db0ce3c905aa58e75be47f84134743709626 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 20 Mar 2017 13:37:28 -0400 Subject: [PATCH] Make sure to compare connection kwargs in storage copy fast-path This ensures that if storage is on different hosts, then we use the slower but correct code path . --- storage/cloud.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/storage/cloud.py b/storage/cloud.py index 9d0ae01d5..ff7f1a281 100644 --- a/storage/cloud.py +++ b/storage/cloud.py @@ -261,14 +261,30 @@ class _CloudStorage(BaseStorageV2): if (self.__class__ == destination.__class__ and self._access_key and self._secret_key and self._access_key == destination._access_key and - self._secret_key == destination._secret_key): + self._secret_key == destination._secret_key and + self._connect_kwargs == destination._connect_kwargs): + + # Initialize the cloud connection on the destination as well. + destination._initialize_cloud_conn() + + # Check the buckets for both the source and destination locations. + if self._cloud_bucket is None: + logger.error('Cloud bucket not found for location %s; Configuration is probably invalid!', + self._bucket_name) + return + + if destination._cloud_bucket is None: + logger.error('Cloud bucket not found for location %s; Configuration is probably invalid!', + destination._bucket_name) + return + + # Perform the copy. logger.debug('Copying file from %s to %s via a direct boto copy', self._cloud_bucket, destination._cloud_bucket) source_path = self._init_path(path) source_key = self._key_class(self._cloud_bucket, source_path) - destination._initialize_cloud_conn() dest_path = destination._init_path(path) source_key.copy(destination._cloud_bucket, dest_path) return