remove all debug
This commit is contained in:
parent
d8c0f204df
commit
f073d3021d
30
auth.go
30
auth.go
@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -108,7 +107,6 @@ type noAuth struct{}
|
||||
// and the remotely offered authentication methods.
|
||||
// First In, First Out.
|
||||
func NewAutoAuth(login string, secret string) Authorizer {
|
||||
log.Printf("NewAutoAuth(%s, %s)", login, secret)
|
||||
fmap := make([]authfactory, 0)
|
||||
az := &authorizer{factories: fmap, defAuthMux: sync.Mutex{}, defAuth: &nullAuth{}}
|
||||
|
||||
@ -132,7 +130,6 @@ func NewAutoAuth(login string, secret string) Authorizer {
|
||||
// First In, First Out.
|
||||
// It offers the `NewAutoAuth` features.
|
||||
func NewEmptyAuth() Authorizer {
|
||||
log.Printf("NewEmptyAuth()")
|
||||
fmap := make([]authfactory, 0)
|
||||
az := &authorizer{factories: fmap, defAuthMux: sync.Mutex{}, defAuth: &nullAuth{}}
|
||||
return az
|
||||
@ -149,13 +146,11 @@ func NewEmptyAuth() Authorizer {
|
||||
// without any synchronisation!!
|
||||
// Still applicable with `BasicAuth` within go routines.
|
||||
func NewPreemptiveAuth(auth Authenticator) Authorizer {
|
||||
log.Printf("NewPreemptiveAuth()")
|
||||
return &preemptiveAuthorizer{auth: auth}
|
||||
}
|
||||
|
||||
// NewAuthenticator creates an Authenticator (Shim) per request
|
||||
func (a *authorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
|
||||
log.Printf("authorizer.NewAuthenticator()")
|
||||
var retryBuf io.Reader = body
|
||||
if body != nil {
|
||||
// If the authorization fails, we will need to restart reading
|
||||
@ -182,7 +177,6 @@ func (a *authorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader)
|
||||
// AddAuthenticator appends the AuthFactory to our factories.
|
||||
// It converts the key to lower case and preserves the order.
|
||||
func (a *authorizer) AddAuthenticator(key string, fn AuthFactory) {
|
||||
log.Printf("authorizer.AddAuthenticator(%s)", key)
|
||||
key = strings.ToLower(key)
|
||||
for _, f := range a.factories {
|
||||
if f.key == key {
|
||||
@ -194,7 +188,6 @@ func (a *authorizer) AddAuthenticator(key string, fn AuthFactory) {
|
||||
|
||||
// factory picks all valid Authenticators based on Www-Authenticate headers
|
||||
func (a *authorizer) factory(c *http.Client, rs *http.Response, path string) (auth Authenticator, err error) {
|
||||
log.Printf("authorizer.factory()")
|
||||
headers := rs.Header.Values("Www-Authenticate")
|
||||
if len(headers) > 0 {
|
||||
auths := make([]Authenticator, 0)
|
||||
@ -230,7 +223,6 @@ func (a *authorizer) factory(c *http.Client, rs *http.Response, path string) (au
|
||||
|
||||
// setDefaultAuthenticator sets the default Authenticator
|
||||
func (a *authorizer) setDefaultAuthenticator(auth Authenticator) {
|
||||
log.Printf("authorizer.setDefaultAuthenticator()")
|
||||
a.defAuthMux.Lock()
|
||||
a.defAuth.Close()
|
||||
a.defAuth = auth
|
||||
@ -239,7 +231,6 @@ func (a *authorizer) setDefaultAuthenticator(auth Authenticator) {
|
||||
|
||||
// Authorize the current request
|
||||
func (s *authShim) Authorize(c *http.Client, rq *http.Request, path string) error {
|
||||
log.Printf("authShim.Authorize()")
|
||||
if err := s.auth.Authorize(c, rq, path); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -261,7 +252,6 @@ func (s *authShim) Authorize(c *http.Client, rq *http.Request, path string) erro
|
||||
// Verify checks for authentication issues and may trigger a re-authentication.
|
||||
// Catches AlgoChangedErr to update the current Authenticator
|
||||
func (s *authShim) Verify(c *http.Client, rs *http.Response, path string) (redo bool, err error) {
|
||||
log.Printf("authShim.Verify()")
|
||||
redo, err = s.auth.Verify(c, rs, path)
|
||||
if err != nil && errors.Is(err, ErrAuthChanged) {
|
||||
if auth, aerr := s.factory(c, rs, path); aerr == nil {
|
||||
@ -277,7 +267,6 @@ func (s *authShim) Verify(c *http.Client, rs *http.Response, path string) (redo
|
||||
|
||||
// Close closes all resources
|
||||
func (s *authShim) Close() error {
|
||||
log.Printf("authShim.Close()")
|
||||
s.auth.Close()
|
||||
s.auth, s.factory = nil, nil
|
||||
if s.body != nil {
|
||||
@ -291,19 +280,16 @@ func (s *authShim) Close() error {
|
||||
// It's not intend to Clone the shim
|
||||
// therefore it returns a noAuth instance
|
||||
func (s *authShim) Clone() Authenticator {
|
||||
log.Printf("authShim.Clone()")
|
||||
return &noAuth{}
|
||||
}
|
||||
|
||||
// String toString
|
||||
func (s *authShim) String() string {
|
||||
log.Printf("authShim.String()")
|
||||
return "AuthShim"
|
||||
}
|
||||
|
||||
// Authorize authorizes the current request with the top most Authorizer
|
||||
func (n *negoAuth) Authorize(c *http.Client, rq *http.Request, path string) error {
|
||||
log.Printf("negoAuth.Authorize()")
|
||||
if len(n.auths) == 0 {
|
||||
return NewPathError("NoAuthenticator", path, 400)
|
||||
}
|
||||
@ -312,7 +298,6 @@ func (n *negoAuth) Authorize(c *http.Client, rq *http.Request, path string) erro
|
||||
|
||||
// Verify verifies the authentication and selects the next one based on the result
|
||||
func (n *negoAuth) Verify(c *http.Client, rs *http.Response, path string) (redo bool, err error) {
|
||||
log.Printf("negoAuth.Verify()")
|
||||
if len(n.auths) == 0 {
|
||||
return false, NewPathError("NoAuthenticator", path, 400)
|
||||
}
|
||||
@ -337,7 +322,6 @@ func (n *negoAuth) Verify(c *http.Client, rs *http.Response, path string) (redo
|
||||
|
||||
// Close will close the underlying authenticators.
|
||||
func (n *negoAuth) Close() error {
|
||||
log.Printf("negoAuth.Close()")
|
||||
for _, a := range n.auths {
|
||||
a.Close()
|
||||
}
|
||||
@ -347,7 +331,6 @@ func (n *negoAuth) Close() error {
|
||||
|
||||
// Clone clones the underlying authenticators.
|
||||
func (n *negoAuth) Clone() Authenticator {
|
||||
log.Printf("negoAuth.Clone()")
|
||||
auths := make([]Authenticator, len(n.auths))
|
||||
for i, e := range n.auths {
|
||||
auths[i] = e.Clone()
|
||||
@ -356,19 +339,16 @@ func (n *negoAuth) Clone() Authenticator {
|
||||
}
|
||||
|
||||
func (n *negoAuth) String() string {
|
||||
log.Printf("negoAuth.String()")
|
||||
return "NegoAuth"
|
||||
}
|
||||
|
||||
// Authorize the current request
|
||||
func (n *noAuth) Authorize(c *http.Client, rq *http.Request, path string) error {
|
||||
log.Printf("noAuth.Authorize()")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Verify checks for authentication issues and may trigger a re-authentication
|
||||
func (n *noAuth) Verify(c *http.Client, rs *http.Response, path string) (redo bool, err error) {
|
||||
log.Printf("noAuth.Verify()")
|
||||
if "" != rs.Header.Get("Www-Authenticate") {
|
||||
err = ErrAuthChanged
|
||||
}
|
||||
@ -377,63 +357,53 @@ func (n *noAuth) Verify(c *http.Client, rs *http.Response, path string) (redo bo
|
||||
|
||||
// Close closes all resources
|
||||
func (n *noAuth) Close() error {
|
||||
log.Printf("noAuth.Close()")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Clone creates a copy of itself
|
||||
func (n *noAuth) Clone() Authenticator {
|
||||
log.Printf("noAuth.Clone()")
|
||||
// no copy due to read only access
|
||||
return n
|
||||
}
|
||||
|
||||
// String toString
|
||||
func (n *noAuth) String() string {
|
||||
log.Printf("noAuth.String()")
|
||||
return "NoAuth"
|
||||
}
|
||||
|
||||
// Authorize the current request
|
||||
func (n *nullAuth) Authorize(c *http.Client, rq *http.Request, path string) error {
|
||||
log.Printf("nullAuth.Authorize()")
|
||||
rq.Header.Set(XInhibitRedirect, "1")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Verify checks for authentication issues and may trigger a re-authentication
|
||||
func (n *nullAuth) Verify(c *http.Client, rs *http.Response, path string) (redo bool, err error) {
|
||||
log.Printf("nullAuth.Verify()")
|
||||
return true, ErrAuthChanged
|
||||
}
|
||||
|
||||
// Close closes all resources
|
||||
func (n *nullAuth) Close() error {
|
||||
log.Printf("nullAuth.Close()")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Clone creates a copy of itself
|
||||
func (n *nullAuth) Clone() Authenticator {
|
||||
log.Printf("nullAuth.Clone()")
|
||||
// no copy due to read only access
|
||||
return n
|
||||
}
|
||||
|
||||
// String toString
|
||||
func (n *nullAuth) String() string {
|
||||
log.Printf("nullAuth.String()")
|
||||
return "NullAuth"
|
||||
}
|
||||
|
||||
// NewAuthenticator creates an Authenticator (Shim) per request
|
||||
func (b *preemptiveAuthorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
|
||||
log.Printf("preemptiveAuthorizer.NewAuthenticator()")
|
||||
return b.auth.Clone(), body
|
||||
}
|
||||
|
||||
// AddAuthenticator Will PANIC because it may only have a single authentication method
|
||||
func (b *preemptiveAuthorizer) AddAuthenticator(key string, fn AuthFactory) {
|
||||
log.Printf("preemptiveAuthorizer.AddAuthenticator()")
|
||||
panic("You're funny! A preemptive authorizer may only have a single authentication method")
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package gowebdav
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@ -20,13 +19,11 @@ func NewBasicAuth(login, secret string) (Authenticator, error) {
|
||||
// Authorize the current request
|
||||
func (b *BasicAuth) Authorize(c *http.Client, rq *http.Request, path string) error {
|
||||
rq.SetBasicAuth(b.user, b.pw)
|
||||
log.Printf("BasicAuth.Authorize : SetBasicAuth(%s, %s)", b.user, b.pw)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Verify verifies if the authentication
|
||||
func (b *BasicAuth) Verify(c *http.Client, rs *http.Response, path string) (redo bool, err error) {
|
||||
log.Printf("BasicAuth.Verify : StatusCode = %d", rs.StatusCode)
|
||||
if rs.StatusCode == 401 {
|
||||
err = NewPathError("Authorize", path, rs.StatusCode)
|
||||
}
|
||||
@ -35,19 +32,16 @@ func (b *BasicAuth) Verify(c *http.Client, rs *http.Response, path string) (redo
|
||||
|
||||
// Close cleans up all resources
|
||||
func (b *BasicAuth) Close() error {
|
||||
log.Printf("BasicAuth.Close")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Clone creates a Copy of itself
|
||||
func (b *BasicAuth) Clone() Authenticator {
|
||||
log.Printf("BasicAuth.Clone")
|
||||
// no copy due to read only access
|
||||
return b
|
||||
}
|
||||
|
||||
// String toString
|
||||
func (b *BasicAuth) String() string {
|
||||
log.Printf("BasicAuth.String")
|
||||
return fmt.Sprintf("BasicAuth login: %s", b.user)
|
||||
}
|
||||
|
23
client.go
23
client.go
@ -5,7 +5,6 @@ import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -27,13 +26,11 @@ type Client struct {
|
||||
|
||||
// NewClient creates a new instance of client
|
||||
func NewClient(uri, user, pw string) *Client {
|
||||
log.Printf("NewClient(%s, %s, %s)", uri, user, pw)
|
||||
return NewAuthClient(uri, NewAutoAuth(user, pw))
|
||||
}
|
||||
|
||||
// NewAuthClient creates a new client instance with a custom Authorizer
|
||||
func NewAuthClient(uri string, auth Authorizer) *Client {
|
||||
log.Printf("NewAuthClient(%s)", uri)
|
||||
c := &http.Client{
|
||||
CheckRedirect: func(rq *http.Request, via []*http.Request) error {
|
||||
if len(via) >= 10 {
|
||||
@ -50,37 +47,31 @@ func NewAuthClient(uri string, auth Authorizer) *Client {
|
||||
|
||||
// SetHeader lets us set arbitrary headers for a given client
|
||||
func (c *Client) SetHeader(key, value string) {
|
||||
log.Printf("Client.SetHeader(%s, %s)", key, value)
|
||||
c.headers.Add(key, value)
|
||||
}
|
||||
|
||||
// SetInterceptor lets us set an arbitrary interceptor for a given client
|
||||
func (c *Client) SetInterceptor(interceptor func(method string, rq *http.Request)) {
|
||||
log.Printf("Client.SetInterceptor()")
|
||||
c.interceptor = interceptor
|
||||
}
|
||||
|
||||
// SetTimeout exposes the ability to set a time limit for requests
|
||||
func (c *Client) SetTimeout(timeout time.Duration) {
|
||||
log.Printf("Client.SetTimeout()")
|
||||
c.c.Timeout = timeout
|
||||
}
|
||||
|
||||
// SetTransport exposes the ability to define custom transports
|
||||
func (c *Client) SetTransport(transport http.RoundTripper) {
|
||||
log.Printf("Client.SetTransport()")
|
||||
c.c.Transport = transport
|
||||
}
|
||||
|
||||
// SetJar exposes the ability to set a cookie jar to the client.
|
||||
func (c *Client) SetJar(jar http.CookieJar) {
|
||||
log.Printf("Client.SetJar()")
|
||||
c.c.Jar = jar
|
||||
}
|
||||
|
||||
// Connect connects to our dav server
|
||||
func (c *Client) Connect() error {
|
||||
log.Printf("Client.Connect()")
|
||||
rs, err := c.options("/")
|
||||
if err != nil {
|
||||
return err
|
||||
@ -114,7 +105,6 @@ type response struct {
|
||||
}
|
||||
|
||||
func getProps(r *response, status string) *props {
|
||||
log.Printf("getProps()")
|
||||
for _, prop := range r.Props {
|
||||
if strings.Contains(prop.Status, status) {
|
||||
return &prop
|
||||
@ -125,7 +115,6 @@ func getProps(r *response, status string) *props {
|
||||
|
||||
// ReadDir reads the contents of a remote directory
|
||||
func (c *Client) ReadDir(path string) ([]os.FileInfo, error) {
|
||||
log.Printf("Client.ReadDir(%s)", path)
|
||||
path = FixSlashes(path)
|
||||
files := make([]os.FileInfo, 0)
|
||||
skipSelf := true
|
||||
@ -193,7 +182,6 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error) {
|
||||
|
||||
// Stat returns the file stats for a specified path
|
||||
func (c *Client) Stat(path string) (os.FileInfo, error) {
|
||||
log.Printf("Client.Stat(%s)", path)
|
||||
var f *File
|
||||
parse := func(resp interface{}) error {
|
||||
r := resp.(*response)
|
||||
@ -246,13 +234,11 @@ func (c *Client) Stat(path string) (os.FileInfo, error) {
|
||||
|
||||
// Remove removes a remote file
|
||||
func (c *Client) Remove(path string) error {
|
||||
log.Printf("Client.Remove(%s)", path)
|
||||
return c.RemoveAll(path)
|
||||
}
|
||||
|
||||
// RemoveAll removes remote files
|
||||
func (c *Client) RemoveAll(path string) error {
|
||||
log.Printf("Client.RemoveAll(%s)", path)
|
||||
rs, err := c.req("DELETE", path, nil, nil)
|
||||
if err != nil {
|
||||
return NewPathError("Remove", path, 400)
|
||||
@ -271,7 +257,6 @@ func (c *Client) RemoveAll(path string) error {
|
||||
|
||||
// Mkdir makes a directory
|
||||
func (c *Client) Mkdir(path string, _ os.FileMode) (err error) {
|
||||
log.Printf("Client.Mkdir(%s)", path)
|
||||
path = FixSlashes(path)
|
||||
status, err := c.mkcol(path)
|
||||
if err != nil {
|
||||
@ -286,7 +271,6 @@ func (c *Client) Mkdir(path string, _ os.FileMode) (err error) {
|
||||
|
||||
// MkdirAll like mkdir -p, but for webdav
|
||||
func (c *Client) MkdirAll(path string, _ os.FileMode) (err error) {
|
||||
log.Printf("Client.MkdirAll(%s)", path)
|
||||
path = FixSlashes(path)
|
||||
status, err := c.mkcol(path)
|
||||
if err != nil {
|
||||
@ -319,19 +303,16 @@ func (c *Client) MkdirAll(path string, _ os.FileMode) (err error) {
|
||||
|
||||
// Rename moves a file from A to B
|
||||
func (c *Client) Rename(oldpath, newpath string, overwrite bool) error {
|
||||
log.Printf("Client.Rename(%s, %s)", oldpath, newpath)
|
||||
return c.copymove("MOVE", oldpath, newpath, overwrite)
|
||||
}
|
||||
|
||||
// Copy copies a file from A to B
|
||||
func (c *Client) Copy(oldpath, newpath string, overwrite bool) error {
|
||||
log.Printf("Client.Copy(%s, %s)", oldpath, newpath)
|
||||
return c.copymove("COPY", oldpath, newpath, overwrite)
|
||||
}
|
||||
|
||||
// Read reads the contents of a remote file
|
||||
func (c *Client) Read(path string) ([]byte, error) {
|
||||
log.Printf("Client.Read(%s)", path)
|
||||
var stream io.ReadCloser
|
||||
var err error
|
||||
|
||||
@ -350,7 +331,6 @@ func (c *Client) Read(path string) ([]byte, error) {
|
||||
|
||||
// ReadStream reads the stream for a given path
|
||||
func (c *Client) ReadStream(path string) (io.ReadCloser, error) {
|
||||
log.Printf("Client.ReadStream(%s)", path)
|
||||
rs, err := c.req("GET", path, nil, nil)
|
||||
if err != nil {
|
||||
return nil, NewPathErrorErr("ReadStream", path, err)
|
||||
@ -373,7 +353,6 @@ func (c *Client) ReadStream(path string) (io.ReadCloser, error) {
|
||||
// this function will emulate the behavior by skipping `offset` bytes and limiting the result
|
||||
// to `length`.
|
||||
func (c *Client) ReadStreamRange(path string, offset, length int64) (io.ReadCloser, error) {
|
||||
log.Printf("Client.ReadStreamRange(%s)", path)
|
||||
rs, err := c.req("GET", path, nil, func(r *http.Request) {
|
||||
if length > 0 {
|
||||
r.Header.Add("Range", fmt.Sprintf("bytes=%d-%d", offset, offset+length-1))
|
||||
@ -408,7 +387,6 @@ func (c *Client) ReadStreamRange(path string, offset, length int64) (io.ReadClos
|
||||
|
||||
// Write writes data to a given path
|
||||
func (c *Client) Write(path string, data []byte, _ os.FileMode) (err error) {
|
||||
log.Printf("Client.Write(%s)", path)
|
||||
s, err := c.put(path, bytes.NewReader(data))
|
||||
if err != nil {
|
||||
return
|
||||
@ -439,7 +417,6 @@ func (c *Client) Write(path string, data []byte, _ os.FileMode) (err error) {
|
||||
|
||||
// WriteStream writes a stream
|
||||
func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) (err error) {
|
||||
log.Printf("Client.WriteStream(%s)", path)
|
||||
|
||||
err = c.createParentCollection(path)
|
||||
if err != nil {
|
||||
|
15
requests.go
15
requests.go
@ -9,7 +9,6 @@ import (
|
||||
)
|
||||
|
||||
func (c *Client) req(method, path string, body io.Reader, intercept func(*http.Request)) (rs *http.Response, err error) {
|
||||
log.Printf("Client.req(%s, %s)", method, path)
|
||||
var redo bool
|
||||
var r *http.Request
|
||||
var uri = PathEscape(Join(c.root, path))
|
||||
@ -17,19 +16,16 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R
|
||||
defer auth.Close()
|
||||
|
||||
for { // TODO auth.continue() strategy(true|n times|until)?
|
||||
log.Printf("Client.req(%s, %s) : NewRequest", method, path)
|
||||
if r, err = http.NewRequest(method, uri, body); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Client.req(%s, %s) : Adding headers", method, path)
|
||||
for k, vals := range c.headers {
|
||||
for _, v := range vals {
|
||||
r.Header.Add(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("Client.req(%s, %s) : Authorize", method, path)
|
||||
if err = auth.Authorize(c.c, r, path); err != nil {
|
||||
return
|
||||
}
|
||||
@ -42,12 +38,10 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R
|
||||
c.interceptor(method, r)
|
||||
}
|
||||
|
||||
log.Printf("Client.req(%s, %s) : Do", method, path)
|
||||
if rs, err = c.c.Do(r); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Client.req(%s, %s) : Verify", method, path)
|
||||
if redo, err = auth.Verify(c.c, rs, path); err != nil {
|
||||
rs.Body.Close()
|
||||
return nil, err
|
||||
@ -62,13 +56,10 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R
|
||||
break
|
||||
}
|
||||
|
||||
log.Printf("Client.req(%s, %s) : done", method, path)
|
||||
|
||||
return rs, err
|
||||
}
|
||||
|
||||
func (c *Client) mkcol(path string) (status int, err error) {
|
||||
log.Printf("Client.mkcol(%s)", path)
|
||||
rs, err := c.req("MKCOL", path, nil, nil)
|
||||
if err != nil {
|
||||
return
|
||||
@ -84,14 +75,12 @@ func (c *Client) mkcol(path string) (status int, err error) {
|
||||
}
|
||||
|
||||
func (c *Client) options(path string) (*http.Response, error) {
|
||||
log.Printf("Client.options(%s)", path)
|
||||
return c.req("OPTIONS", path, nil, func(rq *http.Request) {
|
||||
rq.Header.Add("Depth", "0")
|
||||
})
|
||||
}
|
||||
|
||||
func (c *Client) propfind(path string, self bool, body string, resp interface{}, parse func(resp interface{}) error) error {
|
||||
log.Printf("Client.propfind(%s)", path)
|
||||
rs, err := c.req("PROPFIND", path, strings.NewReader(body), func(rq *http.Request) {
|
||||
if self {
|
||||
rq.Header.Add("Depth", "0")
|
||||
@ -126,7 +115,6 @@ func (c *Client) doCopyMove(
|
||||
r io.ReadCloser,
|
||||
err error,
|
||||
) {
|
||||
log.Printf("Client.doCopyMove(%s, %s, %s)", method, oldpath, newpath)
|
||||
rs, err := c.req(method, oldpath, nil, func(rq *http.Request) {
|
||||
rq.Header.Add("Destination", PathEscape(Join(c.root, newpath)))
|
||||
if overwrite {
|
||||
@ -144,7 +132,6 @@ func (c *Client) doCopyMove(
|
||||
}
|
||||
|
||||
func (c *Client) copymove(method string, oldpath string, newpath string, overwrite bool) (err error) {
|
||||
log.Printf("Client.copymove(%s, %s, %s)", method, oldpath, newpath)
|
||||
s, data, err := c.doCopyMove(method, oldpath, newpath, overwrite)
|
||||
if err != nil {
|
||||
return
|
||||
@ -174,7 +161,6 @@ func (c *Client) copymove(method string, oldpath string, newpath string, overwri
|
||||
}
|
||||
|
||||
func (c *Client) put(path string, stream io.Reader) (status int, err error) {
|
||||
log.Printf("Client.put(%s)", path)
|
||||
rs, err := c.req("PUT", path, stream, nil)
|
||||
if err != nil {
|
||||
return
|
||||
@ -186,7 +172,6 @@ func (c *Client) put(path string, stream io.Reader) (status int, err error) {
|
||||
}
|
||||
|
||||
func (c *Client) createParentCollection(itemPath string) (err error) {
|
||||
log.Printf("Client.createParentCollection(%s)", itemPath)
|
||||
parentPath := path.Dir(itemPath)
|
||||
if parentPath == "." || parentPath == "/" {
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user