List directory contents (PROPFIND Depth 1)
(path: string)
| 663 | |
| 664 | /** List directory contents (PROPFIND Depth 1) */ |
| 665 | async propfind(path: string): Promise<DavResource[]> { |
| 666 | const resp = await this.request("PROPFIND", path, { |
| 667 | headers: { Depth: "1" }, |
| 668 | body: '<?xml version="1.0"?><D:propfind xmlns:D="DAV:"><D:prop><D:resourcetype/><D:getcontentlength/><D:getlastmodified/><D:getetag/></D:prop></D:propfind>', |
| 669 | contentType: "application/xml", |
| 670 | }); |
| 671 | if (!resp.ok && resp.status !== 207) { |
| 672 | if (resp.status === 404 || resp.status === 409) return []; |
| 673 | throw new Error( |
| 674 | `WebDAV PROPFIND failed for ${path}: ${resp.status} ${resp.statusText || ""}`, |
| 675 | ); |
| 676 | } |
| 677 | const xml = await resp.text(); |
| 678 | return parsePropfindResponse(xml, path, this.buildUrl(path)); |
| 679 | } |
| 680 | |
| 681 | /** Safely list directory, create if not exists */ |
| 682 | async safeReadDir(path: string): Promise<DavResource[]> { |
no test coverage detected