Skip to content

Commit

Permalink
fix swift: make create file errors more descriptive
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Chodur <m.chodur@seznam.cz>
  • Loading branch information
FUSAKLA committed Nov 23, 2020
1 parent d8918c3 commit 7afccf8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/objstore/swift/swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,18 @@ func (c *Container) Upload(_ context.Context, name string, r io.Reader) error {
CheckHash: true,
}
if c.useDynamicLargeObjects {
file, err = c.connection.DynamicLargeObjectCreateFile(&opts)
if file, err = c.connection.DynamicLargeObjectCreateFile(&opts); err != nil {
return errors.Wrap(err, "create DLO file")
}
} else {
file, err = c.connection.StaticLargeObjectCreateFile(&opts)
if file, err = c.connection.StaticLargeObjectCreateFile(&opts); err != nil {
return errors.Wrap(err, "create SLO file")
}
}
} else {
file, err = c.connection.ObjectCreate(c.name, name, true, "", "", swift.Headers{})
}
if err != nil {
return errors.Wrap(err, "swift failed to create file")
if file, err = c.connection.ObjectCreate(c.name, name, true, "", "", swift.Headers{}); err != nil {
return errors.Wrap(err, "create file")
}
}
defer runutil.CloseWithLogOnErr(c.logger, file, "upload object close")
if _, err := io.Copy(file, r); err != nil {
Expand Down

0 comments on commit 7afccf8

Please sign in to comment.