Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
8de8ce169b
@ -2,3 +2,9 @@ language: go
|
||||
|
||||
go:
|
||||
- "1.x"
|
||||
|
||||
install:
|
||||
- go get ./...
|
||||
|
||||
script:
|
||||
- go test -v --short ./...
|
@ -337,7 +337,7 @@ func (c *Client) Write(path string, data []byte, _ os.FileMode) error
|
||||
```
|
||||
Write writes data to a given path
|
||||
|
||||
#### <a name="Client.WriteStream">func</a> (\*Client) [WriteStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7798:7878#L363)
|
||||
#### <a name="Client.WriteStream">func</a> (\*Client) [WriteStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7752:7832#L364)
|
||||
``` go
|
||||
func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) error
|
||||
```
|
||||
|
15
client.go
15
client.go
@ -346,21 +346,30 @@ func (c *Client) Write(path string, data []byte, _ os.FileMode) error {
|
||||
return nil
|
||||
|
||||
case 409:
|
||||
if err := c.createParentCollection(path); err == nil {
|
||||
err := c.createParentCollection(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s = c.put(path, bytes.NewReader(data))
|
||||
if s == 200 || s == 201 || s == 204 {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newPathError("Write", path, s)
|
||||
}
|
||||
|
||||
// WriteStream writes a stream
|
||||
func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) error {
|
||||
c.createParentCollection(path)
|
||||
|
||||
err := c.createParentCollection(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s := c.put(path, stream)
|
||||
|
||||
switch s {
|
||||
case 200, 201, 204:
|
||||
return nil
|
||||
|
@ -50,9 +50,6 @@ func main() {
|
||||
}
|
||||
|
||||
c := d.NewClient(*root, *usr, *pw)
|
||||
if err := c.Connect(); err != nil {
|
||||
fail(fmt.Sprintf("Failed to connect due to: %s", err.Error()))
|
||||
}
|
||||
|
||||
cmd := getCmd(*method)
|
||||
|
||||
|
@ -91,7 +91,7 @@ func getDigestAuthorization(digestParts map[string]string) string {
|
||||
case "MD5-sess":
|
||||
ha1 = getMD5(
|
||||
fmt.Sprintf("%s:%v:%s",
|
||||
getMD5(d["username"] + ":" + d["realm"] + ":" + d["password"]),
|
||||
getMD5(d["username"]+":"+d["realm"]+":"+d["password"]),
|
||||
nonceCount,
|
||||
cnonce,
|
||||
),
|
||||
|
12
requests.go
12
requests.go
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
"errors"
|
||||
"path/filepath"
|
||||
@ -135,8 +136,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:
|
||||
return errors.New("can not copy/move item [" + oldpath + "] to [" +
|
||||
newpath + "]: destination path does not exist or wrong XML content of the request")
|
||||
err := c.createParentCollection(newpath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.copymove(method, oldpath, newpath, overwrite)
|
||||
}
|
||||
|
||||
return newPathError(method, oldpath, s)
|
||||
@ -152,8 +157,7 @@ func (c *Client) put(path string, stream io.Reader) int {
|
||||
return rs.StatusCode
|
||||
}
|
||||
|
||||
|
||||
func (c *Client) createParentCollection(itemPath string) (err error) {
|
||||
parentPath := filepath.Dir(itemPath)
|
||||
parentPath := path.Dir(itemPath)
|
||||
return c.MkdirAll(parentPath, 0755)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user