Add diagnostics for MKCOL failures in ensureParent method
This commit is contained in:
@@ -77,11 +77,15 @@ func (c *WebDAVClient) ensureParent(ctx context.Context, remotePath string) erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// Read body for diagnostics
|
||||||
|
b, _ := io.ReadAll(resp.Body)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
// 201 created, 405 exists — ignore
|
// 201 created, 405 exists — ignore
|
||||||
if resp.StatusCode == 201 || resp.StatusCode == 405 {
|
if resp.StatusCode == 201 || resp.StatusCode == 405 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// Any other status is an error: return with diagnostics so caller can log and act on it
|
||||||
|
return fmt.Errorf("MKCOL failed for %s: status=%d body=%s", mkurl, resp.StatusCode, string(b))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user