fix close

This commit is contained in:
Christoph Polcin 2018-05-17 01:17:14 +02:00
parent 0e7fe90d28
commit 7ea52a8e4f
2 changed files with 4 additions and 5 deletions

View File

@ -165,7 +165,7 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error)
``` ```
ReadDir reads the contents of a remote directory ReadDir reads the contents of a remote directory
#### <a name="Client.ReadStream">func</a> (\*Client) [ReadStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6692:6755#L313) #### <a name="Client.ReadStream">func</a> (\*Client) [ReadStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=6691:6754#L312)
``` go ``` go
func (c *Client) ReadStream(path string) (io.ReadCloser, error) func (c *Client) ReadStream(path string) (io.ReadCloser, error)
``` ```
@ -213,13 +213,13 @@ func (c *Client) Stat(path string) (os.FileInfo, error)
``` ```
Stat returns the file stats for a specified path Stat returns the file stats for a specified path
#### <a name="Client.Write">func</a> (\*Client) [Write](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7046:7115#L328) #### <a name="Client.Write">func</a> (\*Client) [Write](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7045:7114#L327)
``` go ``` go
func (c *Client) Write(path string, data []byte, _ os.FileMode) error func (c *Client) Write(path string, data []byte, _ os.FileMode) error
``` ```
Write writes data to a given path 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=7517:7597#L350) #### <a name="Client.WriteStream">func</a> (\*Client) [WriteStream](https://github.com/studio-b12/gowebdav/blob/master/client.go?s=7516:7596#L349)
``` go ``` go
func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) error func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) error
``` ```

View File

@ -295,11 +295,10 @@ func (c *Client) Read(path string) ([]byte, error) {
var stream io.ReadCloser var stream io.ReadCloser
var err error var err error
defer stream.Close()
if stream, err = c.ReadStream(path); err != nil { if stream, err = c.ReadStream(path); err != nil {
return nil, err return nil, err
} }
defer stream.Close()
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
_, err = buf.ReadFrom(stream) _, err = buf.ReadFrom(stream)