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 4497d6c973
commit c4d845cb6c
1 changed files with 10 additions and 8 deletions

View File

@ -457,14 +457,16 @@ func (d *driver) swiftPath(path string) string {
func (d *driver) createParentFolder(path string) (string, error) {
dir := gopath.Dir(path)
if dir != "/" {
_, _, err := d.Conn.Object(d.Container, d.swiftPath(dir))
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)
if err != nil {
return dir, err
}
if dir == "/" {
return dir, nil
}
_, _, err := d.Conn.Object(d.Container, d.swiftPath(dir))
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, "", directoryMimeType, nil)
if err != nil {
return dir, err
}
}