Skip to content

Commit

Permalink
Merge pull request #862 from dhermes/fix-blob-exists
Browse files Browse the repository at this point in the history
Making Blob.exists() work as Bucket.exists().
  • Loading branch information
dhermes committed May 7, 2015
2 parents d134452 + bf8b655 commit a9bc7fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gcloud/storage/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def list_buckets(project=None, max_results=None, page_token=None, prefix=None,
# class has it as a reserved property.
if page_token is not None:
result.next_page_token = page_token
return iter(result)
return result


def get_bucket(bucket_name, connection=None):
Expand Down
7 changes: 6 additions & 1 deletion gcloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,14 @@ def exists(self, connection=None):
# We only need the status code (200 or not) so we seek to
# minimize the returned payload.
query_params = {'fields': 'name'}
# We intentionally pass `_target_object=None` since fields=name
# would limit the local properties.
connection.api_request(method='GET', path=self.path,
query_params=query_params,
_target_object=self)
_target_object=None)
# NOTE: This will not fail immediately in a batch. However, when
# Batch.finish() is called, the resulting `NotFound` will be
# raised.
return True
except NotFound:
return False
Expand Down

0 comments on commit a9bc7fe

Please sign in to comment.