Add diagnostics for MKCOL failures in ensureParent method

This commit is contained in:
Leon Bösche
2026-01-31 23:17:48 +01:00
parent 75a796a43d
commit 367afab430

View File

@@ -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
} }