1
mirror of https://github.com/rclone/rclone synced 2025-03-24 07:04:23 +01:00

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 
This commit is contained in:
John Leach 2017-10-25 00:17:13 +01:00 committed by Nick Craig-Wood
parent fafaea7edc
commit 1602a3a055

@ -788,7 +788,11 @@ func urlEncode(str string) string {
// container. It returns a string which prefixes current segments. // 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) { func (o *Object) updateChunks(in0 io.Reader, headers swift.Headers, size int64, contentType string) (string, error) {
// Create the segmentsContainer if it doesn't exist // 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 { if err != nil {
return "", err return "", err
} }