@@ -202,6 +202,7 @@ def _build_default_global_options():
202202 'leave_segments' : False ,
203203 'changed' : None ,
204204 'skip_identical' : False ,
205+ 'skip_container_put' : False ,
205206 'version_id' : None ,
206207 'yes_all' : False ,
207208 'read_acl' : None ,
@@ -1465,6 +1466,7 @@ def upload(self, container, objects, options=None):
14651466 'leave_segments': False,
14661467 'changed': None,
14671468 'skip_identical': False,
1469+ 'skip_container_put': False,
14681470 'fail_fast': False,
14691471 'dir_marker': False # Only for None sources
14701472 }
@@ -1490,54 +1492,57 @@ def upload(self, container, objects, options=None):
14901492 # the object name. (same as passing --object-name).
14911493 container , _sep , pseudo_folder = container .partition ('/' )
14921494
1493- # Try to create the container, just in case it doesn't exist. If this
1494- # fails, it might just be because the user doesn't have container PUT
1495- # permissions, so we'll ignore any error. If there's really a problem,
1496- # it'll surface on the first object PUT.
1497- policy_header = {}
1498- _header = split_headers (options ["header" ])
1499- if POLICY in _header :
1500- policy_header [POLICY ] = \
1501- _header [POLICY ]
1502- create_containers = [
1503- self .thread_manager .container_pool .submit (
1504- self ._create_container_job , container , headers = policy_header )
1505- ]
1495+ if not options ['skip_container_put' ]:
1496+ # Try to create the container, just in case it doesn't exist. If
1497+ # this fails, it might just be because the user doesn't have
1498+ # container PUT permissions, so we'll ignore any error. If there's
1499+ # really a problem, it'll surface on the first object PUT.
1500+ policy_header = {}
1501+ _header = split_headers (options ["header" ])
1502+ if POLICY in _header :
1503+ policy_header [POLICY ] = \
1504+ _header [POLICY ]
1505+ create_containers = [
1506+ self .thread_manager .container_pool .submit (
1507+ self ._create_container_job , container ,
1508+ headers = policy_header )
1509+ ]
15061510
1507- # wait for first container job to complete before possibly attempting
1508- # segment container job because segment container job may attempt
1509- # to HEAD the first container
1510- for r in interruptable_as_completed (create_containers ):
1511- res = r .result ()
1512- yield res
1511+ # wait for first container job to complete before possibly
1512+ # attempting segment container job because segment container job
1513+ # may attempt to HEAD the first container
1514+ for r in interruptable_as_completed (create_containers ):
1515+ res = r .result ()
1516+ yield res
15131517
1514- if segment_size :
1515- seg_container = container + '_segments'
1516- if options ['segment_container' ]:
1517- seg_container = options ['segment_container' ]
1518- if seg_container != container :
1519- if not policy_header :
1520- # Since no storage policy was specified on the command
1521- # line, rather than just letting swift pick the default
1522- # storage policy, we'll try to create the segments
1523- # container with the same policy as the upload container
1524- create_containers = [
1525- self .thread_manager .container_pool .submit (
1526- self ._create_container_job , seg_container ,
1527- policy_source = container
1528- )
1529- ]
1530- else :
1531- create_containers = [
1532- self .thread_manager .container_pool .submit (
1533- self ._create_container_job , seg_container ,
1534- headers = policy_header
1535- )
1536- ]
1518+ if segment_size :
1519+ seg_container = container + '_segments'
1520+ if options ['segment_container' ]:
1521+ seg_container = options ['segment_container' ]
1522+ if seg_container != container :
1523+ if not policy_header :
1524+ # Since no storage policy was specified on the command
1525+ # line, rather than just letting swift pick the default
1526+ # storage policy, we'll try to create the segments
1527+ # container with the same policy as the upload
1528+ # container
1529+ create_containers = [
1530+ self .thread_manager .container_pool .submit (
1531+ self ._create_container_job , seg_container ,
1532+ policy_source = container
1533+ )
1534+ ]
1535+ else :
1536+ create_containers = [
1537+ self .thread_manager .container_pool .submit (
1538+ self ._create_container_job , seg_container ,
1539+ headers = policy_header
1540+ )
1541+ ]
15371542
1538- for r in interruptable_as_completed (create_containers ):
1539- res = r .result ()
1540- yield res
1543+ for r in interruptable_as_completed (create_containers ):
1544+ res = r .result ()
1545+ yield res
15411546
15421547 # We maintain a results queue here and a separate thread to monitor
15431548 # the futures because we want to get results back from potential
0 commit comments