MCPcopy Create free account
hub / github.com/codedogQBY/ReadAny / mkcol

Method mkcol

packages/core/src/sync/webdav-client.ts:404–424  ·  view source on GitHub ↗

Create a directory (MKCOL)

(path: string)

Source from the content-addressed store, hash-verified

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> {

Callers 2

ensureDirectoryMethod · 0.95
ensureDirectoriesMethod · 0.80

Calls 3

requestMethod · 0.95
propfindExistsMethod · 0.95
toCollectionPathFunction · 0.85

Tested by

no test coverage detected