Simplify code that handles non existing manifests
Signed-off-by: Sylvain Baubeau <sbaubeau@redhat.com>
This commit is contained in:
parent
5e650a820a
commit
d8d50fb0e0
1 changed files with 8 additions and 15 deletions
|
@ -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))
|
||||
if err != nil {
|
||||
if swiftErr, ok := err.(*swift.Error); ok {
|
||||
if swiftErr.StatusCode == 404 {
|
||||
if swiftErr, ok := err.(*swift.Error); ok && swiftErr.StatusCode == 404 {
|
||||
// Create a object manifest
|
||||
if dir, err := d.createParentFolder(path); err != nil {
|
||||
return bytesRead, parseError(dir, err)
|
||||
}
|
||||
headers := make(swift.Headers)
|
||||
headers["X-Object-Manifest"] = segmentsContainer + "/" + d.swiftPath(path)
|
||||
manifest, err := d.Conn.ObjectCreate(d.Container, d.swiftPath(path), false, "",
|
||||
d.getContentType(), headers)
|
||||
manifest.Close()
|
||||
manifest, err := d.createManifest(path)
|
||||
if err != nil {
|
||||
return bytesRead, parseError(path, err)
|
||||
}
|
||||
} else {
|
||||
return bytesRead, parseError(path, err)
|
||||
}
|
||||
manifest.Close()
|
||||
} else {
|
||||
return bytesRead, parseError(path, err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue