From 1602a3a05552bffff6e22a39a26cee36a29cbb23 Mon Sep 17 00:00:00 2001 From: John Leach Date: Wed, 25 Oct 2017 00:17:13 +0100 Subject: [PATCH] Check if swift segments container exists before create Avoids blindly trying to create the segments container, which can fail if the authentication credentials don't allow container creates or updates. Fixes #1769 --- swift/swift.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/swift/swift.go b/swift/swift.go index c97e5e959..c4312ffb2 100644 --- a/swift/swift.go +++ b/swift/swift.go @@ -788,7 +788,11 @@ func urlEncode(str string) string { // container. It returns a string which prefixes current segments. func (o *Object) updateChunks(in0 io.Reader, headers swift.Headers, size int64, contentType string) (string, error) { // Create the segmentsContainer if it doesn't exist - err := o.fs.c.ContainerCreate(o.fs.segmentsContainer, nil) + var err error = swift.ContainerNotFound + _, _, err = o.fs.c.Container(o.fs.segmentsContainer) + if err == swift.ContainerNotFound { + err = o.fs.c.ContainerCreate(o.fs.segmentsContainer, nil) + } if err != nil { return "", err }