Remove one level of indentation in swift path handling code

Signed-off-by: Sylvain Baubeau <sbaubeau@redhat.com>
This commit is contained in:
Sylvain Baubeau 2015-05-29 16:14:12 +02:00
parent 75ce67c469
commit 4e619bc9b1

View file

@ -457,14 +457,16 @@ func (d *driver) swiftPath(path string) string {
func (d *driver) createParentFolder(path string) (string, error) { func (d *driver) createParentFolder(path string) (string, error) {
dir := gopath.Dir(path) dir := gopath.Dir(path)
if dir != "/" { if dir == "/" {
_, _, err := d.Conn.Object(d.Container, d.swiftPath(dir)) return dir, nil
if swiftErr, ok := err.(*swift.Error); ok && swiftErr.StatusCode == 404 { }
_, err := d.Conn.ObjectPut(d.Container, d.swiftPath(dir), bytes.NewReader(make([]byte, 0)),
false, "", "application/directory", nil) _, _, err := d.Conn.Object(d.Container, d.swiftPath(dir))
if err != nil { if swiftErr, ok := err.(*swift.Error); ok && swiftErr.StatusCode == 404 {
return dir, err _, err := d.Conn.ObjectPut(d.Container, d.swiftPath(dir), bytes.NewReader(make([]byte, 0)),
} false, "", directoryMimeType, nil)
if err != nil {
return dir, err
} }
} }