Creating parent collection method was added (#22)
* method for creating parent collection was added to Client struct "func (c *Client) createParentCollection(itemPath string) error" was added to request.go file * using Client's method to create parent collection in following methods: Client.Write() Client.WriteStream() Client.copymove() deadlock is impossible in method Client.copymove() because of paragraph #6 section 9.8.5 (https://tools.ietf.org/html/rfc4918#section-9.8.5) and paragraph #6 section 9.9.4 (https://tools.ietf.org/html/rfc4918#section-9.9.4) of RFC 4918 (https://tools.ietf.org/html/rfc4918) * install dependencies script was added to Travis-CI file * testing was added to Travis-CI file * error wrapping was removed from Client.put() method * using an early return on error in case of 409 in Client.Write() method
This commit is contained in:
committed by
Christoph Polcin
parent
28039fda22
commit
83e3d1e31e
13
requests.go
13
requests.go
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"path"
|
||||
)
|
||||
|
||||
func (c *Client) req(method, path string, body io.Reader, intercept func(*http.Request)) (req *http.Response, err error) {
|
||||
@@ -133,7 +134,12 @@ func (c *Client) copymove(method string, oldpath string, newpath string, overwri
|
||||
log(fmt.Sprintf(" TODO handle %s - %s multistatus result %s", method, oldpath, String(data)))
|
||||
|
||||
case 409:
|
||||
// TODO create dst path
|
||||
err := c.createParentCollection(newpath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.copymove(method, oldpath, newpath, overwrite)
|
||||
}
|
||||
|
||||
return newPathError(method, oldpath, s)
|
||||
@@ -148,3 +154,8 @@ func (c *Client) put(path string, stream io.Reader) int {
|
||||
|
||||
return rs.StatusCode
|
||||
}
|
||||
|
||||
func (c *Client) createParentCollection(itemPath string) (err error) {
|
||||
parentPath := path.Dir(itemPath)
|
||||
return c.MkdirAll(parentPath, 0755)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user