duplicity-team team mailing list archive
-
duplicity-team team
-
Mailing list archive
-
Message #02236
[Merge] lp:~johnleach/duplicity/1315437-swift-container-create into lp:duplicity
John Leach has proposed merging lp:~johnleach/duplicity/1315437-swift-container-create into lp:duplicity.
Requested reviews:
duplicity-team (duplicity-team)
Related bugs:
Bug #1315437 in Duplicity: "swift backend aborts if container create fails due to access controls"
https://bugs.launchpad.net/duplicity/+bug/1315437
For more details, see:
https://code.launchpad.net/~johnleach/duplicity/1315437-swift-container-create/+merge/218373
--
https://code.launchpad.net/~johnleach/duplicity/1315437-swift-container-create/+merge/218373
Your team duplicity-team is requested to review the proposed merge of lp:~johnleach/duplicity/1315437-swift-container-create into lp:duplicity.
=== modified file 'duplicity/backends/swiftbackend.py'
--- duplicity/backends/swiftbackend.py 2014-04-29 23:49:01 +0000
+++ duplicity/backends/swiftbackend.py 2014-05-06 09:42:02 +0000
@@ -72,13 +72,25 @@
self.container = parsed_url.path.lstrip('/')
+ container_metadata = None
try:
self.conn = Connection(**conn_kwargs)
- self.conn.put_container(self.container)
- except Exception as e:
- log.FatalError("Connection failed: %s %s"
- % (e.__class__.__name__, util.uexc(e)),
- log.ErrorCode.connection_failed)
+ container_metadata = self.conn.head_container(self.container)
+ except ClientException:
+ pass
+ except Exception, e:
+ log.FatalError("Connection failed: %s %s"
+ % (e.__class__.__name__, str(e)),
+ log.ErrorCode.connection_failed)
+
+ if container_metadata is None:
+ log.Info("Creating container %s" % self.container)
+ try:
+ self.conn.put_container(self.container)
+ except Exception, e:
+ log.FatalError("Container creation failed: %s %s"
+ % (e.__class__.__name__, str(e)),
+ log.ErrorCode.connection_failed)
def _error_code(self, operation, e):
if isinstance(e, self.resp_exc):
Follow ups