Create a directory (MKCOL)
(path: string)
| 402 | |
| 403 | /** Create a directory (MKCOL) */ |
| 404 | async mkcol(path: string): Promise<void> { |
| 405 | const collectionPath = toCollectionPath(path); |
| 406 | let resp: Response; |
| 407 | try { |
| 408 | resp = await this.request("MKCOL", collectionPath); |
| 409 | } catch (e) { |
| 410 | if (await this.propfindExists(collectionPath, { timeoutMs: DIRECTORY_PROBE_TIMEOUT_MS })) { |
| 411 | console.warn(`[WebDAV] MKCOL ${path} failed but directory exists; continuing`); |
| 412 | return; |
| 413 | } |
| 414 | throw e; |
| 415 | } |
| 416 | const status = resp.status; |
| 417 | if (resp.ok || status === 201) { |
| 418 | return; |
| 419 | } |
| 420 | if (status === 405 || status === 409) { |
| 421 | return; |
| 422 | } |
| 423 | throw new Error(`WebDAV MKCOL failed for ${path}: ${status} ${resp.statusText || ""}`); |
| 424 | } |
| 425 | |
| 426 | /** Ensure a full directory path exists (creates each segment) */ |
| 427 | async ensureDirectory(path: string): Promise<void> { |
no test coverage detected