Simplify code that handles non existing manifests

Signed-off-by: Sylvain Baubeau <sbaubeau@redhat.com>
This commit is contained in:
Sylvain Baubeau 2015-05-29 15:50:22 +02:00
parent 5e650a820a
commit d8d50fb0e0

View file

@ -253,23 +253,16 @@ func (d *driver) WriteStream(ctx context.Context, path string, offset int64, rea
info, _, err := d.Conn.Object(d.Container, d.swiftPath(path)) info, _, err := d.Conn.Object(d.Container, d.swiftPath(path))
if err != nil { if err != nil {
if swiftErr, ok := err.(*swift.Error); ok { if swiftErr, ok := err.(*swift.Error); ok && swiftErr.StatusCode == 404 {
if swiftErr.StatusCode == 404 { // Create a object manifest
// Create a object manifest if dir, err := d.createParentFolder(path); err != nil {
if dir, err := d.createParentFolder(path); err != nil { return bytesRead, parseError(dir, err)
return bytesRead, parseError(dir, err) }
} manifest, err := d.createManifest(path)
headers := make(swift.Headers) if err != nil {
headers["X-Object-Manifest"] = segmentsContainer + "/" + d.swiftPath(path)
manifest, err := d.Conn.ObjectCreate(d.Container, d.swiftPath(path), false, "",
d.getContentType(), headers)
manifest.Close()
if err != nil {
return bytesRead, parseError(path, err)
}
} else {
return bytesRead, parseError(path, err) return bytesRead, parseError(path, err)
} }
manifest.Close()
} else { } else {
return bytesRead, parseError(path, err) return bytesRead, parseError(path, err)
} }