simplify 409 write error handler

This commit is contained in:
Christoph Polcin
2018-05-16 23:39:37 +02:00
parent 65a34986d4
commit 410e447c49
2 changed files with 4 additions and 8 deletions

View File

@@ -323,18 +323,14 @@ func (c *Client) Write(path string, data []byte, _ os.FileMode) error {
return nil
case 409:
if idx := strings.LastIndex(path, "/"); idx == -1 {
// faulty root
return newPathError("Write", path, 500)
} else {
if err := c.MkdirAll(path[0:idx+1], 0755); err == nil {
if i := strings.LastIndex(path, "/"); i > -1 {
if err := c.MkdirAll(path[0:i+1], 0755); err == nil {
s = c.put(path, bytes.NewReader(data))
if s == 200 || s == 201 {
if s == 200 || s == 201 || s == 204 {
return nil
}
}
}
}
return newPathError("Write", path, s)