still more debug

This commit is contained in:
shoopea 2024-01-20 12:05:02 +01:00
parent e3bd2a5fb2
commit 1dc1a2b378

View File

@ -9,6 +9,7 @@ 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)", req, path)
var redo bool
var r *http.Request
var uri = PathEscape(Join(c.root, path))
@ -60,6 +61,7 @@ func (c *Client) req(method, path string, body io.Reader, intercept func(*http.R
}
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
@ -75,12 +77,14 @@ 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")
@ -115,6 +119,7 @@ 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 {
@ -132,6 +137,7 @@ 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
@ -161,6 +167,7 @@ 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
@ -172,6 +179,7 @@ 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