forked from TrueCloudLab/distribution
Simplify code that handles non existing manifests
Signed-off-by: Sylvain Baubeau <sbaubeau@redhat.com>
This commit is contained in:
parent
16a49ade16
commit
8a22c0f4e1
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))
|
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)
|
||||||
}
|
}
|
||||||
headers := make(swift.Headers)
|
manifest, err := d.createManifest(path)
|
||||||
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 {
|
if err != nil {
|
||||||
return bytesRead, parseError(path, err)
|
return bytesRead, parseError(path, err)
|
||||||
}
|
}
|
||||||
} else {
|
manifest.Close()
|
||||||
return bytesRead, parseError(path, err)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return bytesRead, parseError(path, err)
|
return bytesRead, parseError(path, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue