@@ -440,7 +440,7 @@ def delete_blobs(self, blobs, on_error=None, client=None):
440440 raise
441441
442442 def copy_blob (self , blob , destination_bucket , new_name = None ,
443- client = None , preserve_acl = False ):
443+ client = None , preserve_acl = True ):
444444 """Copy the given blob to the given bucket, optionally with a new name.
445445
446446 :type blob: :class:`google.cloud.storage.blob.Blob`
@@ -460,7 +460,7 @@ def copy_blob(self, blob, destination_bucket, new_name=None,
460460
461461 :type preserve_acl: bool
462462 :param preserve_acl: Optional. Copies ACL from old blob to new blob.
463- Default: False .
463+ Default: True .
464464
465465 :rtype: :class:`google.cloud.storage.blob.Blob`
466466 :returns: The new Blob.
@@ -470,14 +470,15 @@ def copy_blob(self, blob, destination_bucket, new_name=None,
470470 new_name = blob .name
471471 new_blob = Blob (bucket = destination_bucket , name = new_name )
472472 api_path = blob .path + '/copyTo' + new_blob .path
473+ if not preserve_acl :
474+ new_blob .acl .reset ()
475+ new_blob .acl .save ()
473476 copy_result = client .connection .api_request (
474477 method = 'POST' , path = api_path , _target_object = new_blob )
475478 new_blob ._set_properties (copy_result )
476- if preserve_acl :
477- new_blob .acl .save (blob .acl )
478479 return new_blob
479480
480- def rename_blob (self , blob , new_name , client = None , preserve_acl = False ):
481+ def rename_blob (self , blob , new_name , client = None ):
481482 """Rename the given blob using copy and delete operations.
482483
483484 Effectively, copies blob to the same bucket with a new name, then
@@ -500,15 +501,10 @@ def rename_blob(self, blob, new_name, client=None, preserve_acl=False):
500501 :param client: Optional. The client to use. If not passed, falls back
501502 to the ``client`` stored on the current bucket.
502503
503- :type preserve_acl: bool
504- :param preserve_acl: Optional. Copies ACL from old blob to renamed
505- blob. Default: False.
506-
507504 :rtype: :class:`Blob`
508505 :returns: The newly-renamed blob.
509506 """
510- new_blob = self .copy_blob (blob , self , new_name , client = client ,
511- preserve_acl = preserve_acl )
507+ new_blob = self .copy_blob (blob , self , new_name , client = client )
512508 blob .delete (client = client )
513509 return new_blob
514510
0 commit comments